Rob Cliffe wrote:

But when a frozen list a.k.a. tuple would be created - either directly, or by setting a list's mutable flag to False which would really turn it into a tuple - the size *would* be known.

But at that point the object consists of two memory blocks -- one
containing just the object header and a pointer to the items, and
the other containing the items.

To turn that into a true tuple structure would require resizing
the main object block to be big enough to hold the items and
copying them into it. The main object can't be moved (because
there are PyObject *s all over the place pointing to it), so
if there's not enough room at its current location, you're out
of luck.

So lists frozen after creation would have to remain as two blocks,
making them second-class citizens compared to those that were
created frozen. Either that or store all lists/tuples as two
blocks, and give up some of the performance advantages of the
current tuple structure.

--
Greg
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to