Skip to content

Conversation

@ZhiyuanChen
Copy link

Slightly increase spped by reducing two for loop to one

Slightly increase spped by reducing two for loop to one
@alexnguyen2201
Copy link

alexnguyen2201 commented May 1, 2020

@zyc-ai a comprehension list is faster than a loop

@ZhiyuanChen
Copy link
Author

a comprehension list is faster than a loop

It seems not in the case of Python https://stackoverflow.com/a/43677631/8791650.

@kanasite
Copy link

kanasite commented Nov 3, 2020

a comprehension list is faster than a loop

It seems not in the case of Python https://stackoverflow.com/a/43677631/8791650.

I beg to diff, consider doing this instead

def square_sum4(numbers):
return(sum([i**2 for i in numbers]))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants