Skip to content

Use all build-in function#14

Merged
Jackojc merged 2 commits into
HopsonCommunity:developfrom
Hazurl:use-all-function
Jan 23, 2018
Merged

Use all build-in function#14
Jackojc merged 2 commits into
HopsonCommunity:developfrom
Hazurl:use-all-function

Conversation

@Hazurl
Copy link
Copy Markdown
Collaborator

@Hazurl Hazurl commented Jan 23, 2018

No description provided.

@Jackojc
Copy link
Copy Markdown
Contributor

Jackojc commented Jan 23, 2018

ah yes, very nice

@Jackojc Jackojc merged commit 1149998 into HopsonCommunity:develop Jan 23, 2018
@Jackojc
Copy link
Copy Markdown
Contributor

Jackojc commented Jan 23, 2018

just to note, this may potentially be slower due to having to evaluate all the expressions in the list, but its a good use of python features and its looks great!

@iCiaran
Copy link
Copy Markdown

iCiaran commented Jan 24, 2018

I believe if you remove the [] it will be evaluated lazily. (and therefore the same speed as previously).

Did a couple of tests, seems to be correct

>>> import timeit
>>> timeit.timeit('any([x == 52 for x in l])',setup='l = [x for x in range(1000)]', number=10000)
0.4704603556645566
>>> timeit.timeit('any(x == 52 for x in l)',setup='l = [x for x in range(1000)]', number=10000)
0.04013646315647179

Changed in #15

@Hazurl Hazurl deleted the use-all-function branch January 24, 2018 11:01
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