lists, performance..

gabor gabor at realtime.sk
Thu Oct 31 11:38:25 EST 2002


On Thu, 2002-10-31 at 17:25, Alex Martelli wrote:
> gabor wrote:
> 
> > hi,
> > 
> > i'm working on a graphic application ( python + opengl)..
> > 
> > and i have some lists of vertices... but that's not important..
> > 
> > let's say a have loooooooong ( long = 500 to 5000 ) lists of relatively
> > simple objects..
> > 
> > 2 questions:
> > 
> > 1. is a list implemented as a vector? i mean looking up the n-th element
> > is done in o[1] (constant time)?
> 
> Yes.
> 
> > i'm worried about how many times would the list resize itself to be able
> > to contain the additional 20elements if i would add them one-by-one
> 
> I think you're worrying about the wrong things: study listobject.c in
> the Python sources to see why.  Rather, I think you should worry about
> the need for deep copies.  Do you REALLY need to keep and reuse the
> small lists that you're adding to the large list, so that the deep
> copy is truly needed, or could you get by in simpler, faster ways?

thanks for your answer....

actually i think the most important thing for me is that the n-th
element can be accessed in o[1]

the next is the need for deep copy...

i think i can reorganize my code to live without it....
i wanted to deep-copy because the created big list will be used in a
different thread than the small ones... so i thouhgt let's have it as
safe as it can be...

so to summarize it:
the best is extend without deep-copy... :-)

thanks,
gabor
-- 
gpg key at www.keyserver.net
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 196 bytes
Desc: This is a digitally signed message part
URL: <http://mail.python.org/pipermail/python-list/attachments/20021031/7e41bfec/attachment.sig>


More information about the Python-list mailing list