Re: Ad hoc lists vs ad hoc tuples

2010-01-28 Thread Duncan Booth
Terry Reedy wrote: > Constant tuples (a tuple whose members are all seen as constants by the > compiler) are now pre-compiled and constructed once and put into the > code object as such rather than re-constructed with each run of the code. Sadly that's not entirely accurate. Tuples whose memb

Re: Ad hoc lists vs ad hoc tuples

2010-01-27 Thread Floris Bruynooghe
On Jan 27, 10:15 pm, Terry Reedy wrote: > On 1/27/2010 12:32 PM, Antoine Pitrou wrote: > > > Le Wed, 27 Jan 2010 02:20:53 -0800, Floris Bruynooghe a écrit : > > >> Is a list or tuple better or more efficient in these situations? > > > Tuples are faster to allocate (they are allocated in one single

Re: Ad hoc lists vs ad hoc tuples

2010-01-27 Thread Terry Reedy
On 1/27/2010 12:32 PM, Antoine Pitrou wrote: Le Wed, 27 Jan 2010 02:20:53 -0800, Floris Bruynooghe a écrit : Is a list or tuple better or more efficient in these situations? Tuples are faster to allocate (they are allocated in one single step) and quite a bit smaller too. In some situations,

Re: Ad hoc lists vs ad hoc tuples

2010-01-27 Thread Antoine Pitrou
Le Wed, 27 Jan 2010 02:20:53 -0800, Floris Bruynooghe a écrit : > > Is a list or tuple better or more efficient in these situations? Tuples are faster to allocate (they are allocated in one single step) and quite a bit smaller too. In some situations, in Python 2.7 and 3.1, they can also be igno

Re: Ad hoc lists vs ad hoc tuples

2010-01-27 Thread Steve Holden
Iain King wrote: > On Jan 27, 10:20 am, Floris Bruynooghe > wrote: >> One thing I ofter wonder is which is better when you just need a >> throwaway sequence: a list or a tuple? E.g.: >> >> if foo in ['some', 'random', 'strings']: >> ... >> if [bool1, bool2, boo3].count(True) != 1: >>... >

Re: Ad hoc lists vs ad hoc tuples

2010-01-27 Thread M.-A. Lemburg
Iain King wrote: > On Jan 27, 10:20 am, Floris Bruynooghe > wrote: >> One thing I ofter wonder is which is better when you just need a >> throwaway sequence: a list or a tuple? E.g.: >> >> if foo in ['some', 'random', 'strings']: >> ... >> if [bool1, bool2, boo3].count(True) != 1: >>... >

Re: Ad hoc lists vs ad hoc tuples

2010-01-27 Thread Iain King
On Jan 27, 10:20 am, Floris Bruynooghe wrote: > One thing I ofter wonder is which is better when you just need a > throwaway sequence: a list or a tuple?  E.g.: > > if foo in ['some', 'random', 'strings']: >     ... > if [bool1, bool2, boo3].count(True) != 1: >    ... > > (The last one only works

Ad hoc lists vs ad hoc tuples

2010-01-27 Thread Floris Bruynooghe
One thing I ofter wonder is which is better when you just need a throwaway sequence: a list or a tuple? E.g.: if foo in ['some', 'random', 'strings']: ... if [bool1, bool2, boo3].count(True) != 1: ... (The last one only works with tuples since python 2.6) Is a list or tuple better or mor