Message193081
> On the contrary, it will reduce memory usage and creation time compared to regular tuples, because in cases like:
> c = a + b
> you do not have to spend time and memory for allocating and copying elements of "a".
This is not a common case. A common case is creating short tuples and keeping a lot of tuples in memory.
> The only case when it could use more memory is if you explicitly delete "c" after that operation. But this can be solved too, internal storage can be resized to a smaller value when its tail elements are not used any more.
No. For fast += you need keep not only a size of tuple, but also a size of of allocated memory. It's a cause of sys.getsizeof([1, 2]) > sys.getsizeof((1, 2)).
For fast + you need even more complicated internal structure.
Tuples should be compact and fast. You shouldn't optimize a rare case at the cost of regression in common usage. |
|
Date |
User |
Action |
Args |
2013-07-15 08:11:00 | serhiy.storchaka | set | recipients:
+ serhiy.storchaka, aleax, terry.reedy, jcea, ethan.furman, Ramchandra Apte, oscarbenjamin, Sergey |
2013-07-15 08:11:00 | serhiy.storchaka | set | messageid: <1373875860.44.0.153582623203.issue18305@psf.upfronthosting.co.za> |
2013-07-15 08:11:00 | serhiy.storchaka | link | issue18305 messages |
2013-07-15 08:11:00 | serhiy.storchaka | create | |
|