STINNER Victor <vstin...@python.org> added the comment:

The main blocker issue (if we decide to accept this feature) is the pickle 
serialization issue.


Serhiy Storchaka:
> No, it is not fully backwards-compatible. First, if pickle a namedtuple, it 
> can't be unpickled in previous versions.

Would it be possible to tell pickle to serialize .isocalendar() as a tuple, and 
deserialize it from a tuple to a structseq? I'm thinking at __getstate__ and 
__setstate__ methods, but I'm not sure how to use them.


Serhiy Storchaka:
> Second, namedtuple is slower and larger than tuple, so it shouldn't be used 
> in memory or performance critical code.

vstinner@apu$ python3
Python 3.7.4 (default, Jul  9 2019, 16:32:37) 
>>> import sys
>>> s=sys.version_info
>>> t=tuple(s)
>>> sys.getsizeof(t), sys.getsizeof(s)
(96, 96)
>>> type(s)
<class 'sys.version_info'>

Hum, structseq and tuple seem to have exactly the same memory footprint: only 
the type is larger, not instances.

According to msg350986, the performance to instanciate a new object is exactly 
the same between tuple and structseq.

----------

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

Reply via email to