[issue19640] Drop _source attribute of namedtuple (waste memory)

2014-03-20 Thread Raymond Hettinger
Raymond Hettinger added the comment: FWIW, the "verbose" option is mentioned as outdated because the "_source" attribute was added. Also, there are real use cases, people are using the _source as writing it to a .py file so that the dynamic namedtuple generation step can be skipped on subsequ

[issue19640] Drop _source attribute of namedtuple (waste memory)

2014-03-20 Thread Raymond Hettinger
Changes by Raymond Hettinger : -- versions: -Python 3.4 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https:

[issue19640] Drop _source attribute of namedtuple (waste memory)

2014-03-20 Thread Raymond Hettinger
Changes by Raymond Hettinger : -- assignee: -> rhettinger ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http

[issue19640] Drop _source attribute of namedtuple (waste memory)

2014-03-18 Thread Eric Snow
Eric Snow added the comment: Also be sure the have Raymond's sign-off before committing anything for this. :) -- ___ Python tracker ___ __

[issue19640] Drop _source attribute of namedtuple (waste memory)

2014-03-18 Thread STINNER Victor
STINNER Victor added the comment: namedtuple_source.patch: Replace _source attribute wasting memory with a property generating the source on demand. The patch adds also unit test for the verbose attribute (which is public and documented, even it is said to be "outdated"). The patch removes al

[issue19640] Drop _source attribute of namedtuple

2014-03-18 Thread Eric Snow
Eric Snow added the comment: It does not necessarily require a metaclass. You can accomplish it using a custom descriptor: class classattr: def __init__(self, getter): self.getter = getter def __get__(self, obj, cls): return self.getter(cls) FWIW, this is a descriptor

[issue19640] Drop _source attribute of namedtuple

2014-03-17 Thread STINNER Victor
STINNER Victor added the comment: > As an alternative, how about turning _source into a property? A class or an instance property? A class property requires a metaclass. I guess that each namedtuple type requires its own metaclass, right? -- ___ Pyt

[issue19640] Drop _source attribute of namedtuple

2013-11-22 Thread Eric Snow
Eric Snow added the comment: A while back, because of those python-ideas discussions, Raymond added a link at the bottom of the namedtuple section of the docs at http://docs.python.org/3.4/library/collections.html#namedtuple-factory-function-for-tuples-with-named-fields. The link points to a

[issue19640] Drop _source attribute of namedtuple

2013-11-22 Thread Éric Araujo
Éric Araujo added the comment: In a first version namedtuple had an argument (named echo or verbose) that would cause the source code to be printed out, for use at the interactive prompt. Raymond later changed it to a _source attribute, more easy to work with than printed output. About the o

[issue19640] Drop _source attribute of namedtuple

2013-11-22 Thread Éric Araujo
Changes by Éric Araujo : -- nosy: +eric.araujo ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.pyt

[issue19640] Drop _source attribute of namedtuple

2013-11-21 Thread Eric Snow
Eric Snow added the comment: As an alternative, how about turning _source into a property? -- nosy: +eric.snow ___ Python tracker ___

[issue19640] Drop _source attribute of namedtuple

2013-11-18 Thread STINNER Victor
STINNER Victor added the comment: > the 5th line allocating the memory memory oops, the 5th line allocating the *most* memory -- ___ Python tracker ___

[issue19640] Drop _source attribute of namedtuple

2013-11-18 Thread Eric V. Smith
Changes by Eric V. Smith : -- nosy: +eric.smith ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.py

[issue19640] Drop _source attribute of namedtuple

2013-11-18 Thread Christian Heimes
Changes by Christian Heimes : -- nosy: +christian.heimes ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https:

[issue19640] Drop _source attribute of namedtuple

2013-11-18 Thread STINNER Victor
STINNER Victor added the comment: I found this issue while using my tracemalloc module to analyze the memory consumption of Python. On the Python test suite, the _source attribute is the 5th line allocating the memory memory: /usr/lib/python3.4/collections/__init__.py: 676.2 kB -- __

[issue19640] Drop _source attribute of namedtuple

2013-11-18 Thread STINNER Victor
New submission from STINNER Victor: The definition of a new nametuple creates a large Python script to create the new type. The code stores the code in a private attribute: namespace = dict(__name__='namedtuple_%s' % typename) exec(class_definition, namespace) result = namespace[typ