No Python 2.0 (was Re: idiom for initial list of lists)
Robin Becker
robin at jessikat.fsnet.co.uk
Sat Sep 9 20:40:07 EDT 2000
In article <8peg3q$ckk$1 at panix3.panix.com>, Aahz Maruch <aahz at panix.com>
writes
....
>I think at the very least anyone proferring a 2.0 solution should
>clearly mention that 2.0 is not shipping yet. I think it's cruel to
>hold out a carrot in front of someone and then snatch it away.
well as the rather moronic instigator of this thread I think the main
problem is that for
>>> def six():
... S=[[] for x in range(100000)]
>>> def one():
... S=[]
... for i in range(100000):
... S.append([])
>>> def four():
... S=map(lambda x:[],range(100000))
I get one ~= 1.49 seconds, six ~= 1.37 seconds and four ~= 1.04 seconds
so no matter what I do it's not obvious what I should do to initialize
long lists. Comprehensions are not fast and I can only get a faster
setup by using a C method eg
>>> def five():
... S=map(_copy_list,100000*[[]])
where five ~= 0.44 seconds
It's not at all obvious to me what the 'correct' list of list setup
idiom is.
--
Robin Becker
More information about the Python-list
mailing list