Size of tuples
Fredrik Lundh
fredrik at pythonware.com
Wed Sep 5 16:04:55 EDT 2001
Peter van der Kamp wrote:
> Does anyone anyone know what the maximum size of
> a tuple can be?
how much memory do you have?
> Examples in documentation only contains a small amount
> of data, but I like to know if they can contain e.g. >100000
> integers. Furthermore I would like to know the consequences
> for performance.
why not try it out? It's not exactly difficult to create large
tuples:
T = tuple(xrange(100001))
> Does the 'x in tuple' statement perform much worse with the
> amounts of data I have in mind?
"in" does a linear search. The more data you have, the longer
time it takes (on average).
on an old 200 mhz box, I can do about ten "100000 in T"
searches per second. Using a dictionary of the same size,
I can do about 200,000 lookups per second.
ymmv, as usual.
</F>
<!-- (the eff-bot guide to) the python standard library:
http://www.pythonware.com/people/fredrik/librarybook.htm
-->
More information about the Python-list
mailing list