[issue28638] Optimize namedtuple creation

Christoph Reiter report at bugs.python.org
Tue Jul 18 06:53:41 EDT 2017


Christoph Reiter added the comment:

Why not just do the following:

>>> from collections import namedtuple
>>> Point = namedtuple('Point', ['x', 'y'])
>>> Point._source
"from collections import namedtuple\nPoint = namedtuple('Point', ['x', 'y'])\n"
>>> 

The docs make it seems as if the primary use case of the _source attribute is
to serialize the definition. Returning a source which produces a class with
different performance/memory characteristics goes against that.

----------
nosy: +lazka

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue28638>
_______________________________________


More information about the Python-bugs-list mailing list