Message203270
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[typename]
result._source = class_definition
This attribute wastes memory, I don't understand the purpose of the attribute. It was not discussed in an issue, so I guess that there is no real use case:
changeset: 68879:bffdd7e9265c
user: Raymond Hettinger <python@rcn.com>
date: Wed Mar 23 12:52:23 2011 -0700
files: Doc/library/collections.rst Lib/collections/__init__.py Lib/test/test_collections.py
description:
Expose the namedtuple source with a _source attribute.
Can we just drop this attribute to reduce the Python memory footprint? |
|
Date |
User |
Action |
Args |
2013-11-18 09:42:10 | vstinner | set | recipients:
+ vstinner, rhettinger |
2013-11-18 09:42:10 | vstinner | set | messageid: <1384767730.42.0.112147293599.issue19640@psf.upfronthosting.co.za> |
2013-11-18 09:42:10 | vstinner | link | issue19640 messages |
2013-11-18 09:42:09 | vstinner | create | |
|