Message203270
| Author |
vstinner |
| Recipients |
rhettinger, vstinner |
| Date |
2013年11月18日.09:42:09 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1384767730.42.0.112147293599.issue19640@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
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? |
|
History
|
|---|
| 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 |
|