how to create a big list of list

  • Thread starter §ä´M¦Û¤vªº¤@¤ù¤Ñ
  • Start date
§

§ä´M¦Û¤vªº¤@¤ù¤Ñ

if i want to create a list of list which size is 2**25

how should i do it?

i have try [ [] for x in xrange(2**25) ]

but it take too long to initial the list

is there any suggestion?

Thanks a lot!
 
G

greg

i have try [ [] for x in xrange(2**25) ]

Are you really going to be adding data to all
of those sublists?

If you're only using them sparsely, it may be
better to use a dictionary in place of the
top level list, and only add sublists as and
when necessary.

Recent Python versions have a built-in type
called defaultdict that makes this kind of
thing easy.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,289
Messages
2,571,450
Members
48,128
Latest member
SantoGepp

Latest Threads

Top