Re: Interesting performance question

2019-09-29 Thread Terry Reedy
On 9/29/2019 9:45 AM, Eryk Sun wrote: On 9/29/19, Anthony Flury via Python-list wrote: Using python 3.6 building a tuple like this : my_tuple = tuple([x*x for x in range(1,1000)]) The list comprehension is implemented internally as a function that builds and returns the list. This function

Re: Interesting performance question

2019-09-29 Thread Eryk Sun
On 9/29/19, Anthony Flury via Python-list wrote: > > Using python 3.6 building a tuple like this : > > my_tuple = tuple([x*x for x in range(1,1000)]) The list comprehension is implemented internally as a function that builds and returns the list. This function creates an empty list and loops over

Interesting performance question

2019-09-29 Thread Anthony Flury via Python-list
I have just noticed an oddity : Using python 3.6 building a tuple like this : my_tuple = tuple([x*x for x in range(1,1000)]) is about 1/3 quicker than     my_tuple = tuple(x*x for x in range(1,1000)) Measurements : $  python3 -m timeit 'my_tuple = tuple([x*x for x in range(1,1000)])' 1