writing code over several lines

P

Peter Hansen

Alex said:
Peter Hansen wrote:
...

One counterexample from the dark ages:

map(twoargsfunc, lotsoffirstargs, (onesecondarg,)*len(lotsoffirstargs))

the memory consumption of all the constructed tuple's elements is
fixed -- sizeof(onesecondarg) if Python has sizeof (don't you wish...;-),
as all slots in the tuple point to that one object.

So, here, the overhead of the structure itself might be important,
since the elements in that structure aren't; so a tuple MAY be a good
thing.

Certainly there are cases, such as your example and doubtless others.

"Initializing constant lists at the beginning of the program" likely
isn't one of them, except in exceptional cases.

-Peter
 

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
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top