Sergey added the comment:

> This is not a common case. A common case is creating short tuples and keeping 
> a lot of tuples in memory.

> For fast += you need keep not only a size of tuple, but also a size of 
> allocated memory. It's a cause of sys.getsizeof([1, 2]) > sys.getsizeof((1, 
> 2)).

Agree. But is it worth worrying about? How much RAM could be taken by it? E.g. 
python test uses ~30000 tuples in peak. So if we add e.g. 32 bytes to tuple 
then python test would use 106MB of RAM instead of 105MB. 1%? ;)

> You shouldn't optimize a rare case at the cost of regression in common usage.

This could optimize many cases, like instant tuple copy, or instant conversions 
of lists to tuples and back, if this idea is extended to lists. It may also 
work for strings.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue18305>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to