Memory overhead for trees?

Aahz aahz at pythoncraft.com
Fri Aug 16 01:09:30 EDT 2002


In article <mailman.1029451414.25268.python-list at python.org>,
=?iso-8859-1?q?Fran=E7ois?= Pinard <pinard at iro.umontreal.ca> wrote:
>
>Do you know how worth the memory savings of using tuples over lists?
>I'm tempted to guess that the savings are not worth all the trouble it
>would take to convert between both when the need of modification arises.

Depends how frequent and local modifications are.  That is, if
full-blown tree rebalancing is rare, I think the memory savings afforded
by tuples probably makes a fair bit of sense, and I think the Timbot
would concur based on comments it has made in the past.

>I've the feeling, too, that sub-classing tuples or lists (only possible in
>recent Python versions) is significantly more economical in memory than
>using traditional classes, while keeping the application in closer touch
>with the built-in speed of the tuple or list implementation.  Moreover,
>that would allow using the sub-classed types in a wider range of Python
>contexts where built-in tuples or lists are directly usable.
>
>Could I hope that sub-classing tuples or lists could be done with only
>little, or maybe no extra memory cost, compared to using tuples or lists
>directly?  Surely, the idea of sub-classing is very attractive, from the
>comfort resulting from possible specialised methods over the built-ins.

Enh.  Not sure that makes much sense.  The only way you'd achieve real
memory savings in a subclass would be through the __slots__ mechanism.
-- 
Aahz (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/

Project Vote Smart: http://www.vote-smart.org/



More information about the Python-list mailing list