[New-bugs-announce] [issue19640] Drop _source attribute of namedtuple

STINNER Victor report at bugs.python.org
Mon Nov 18 10:42:10 CET 2013


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[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 at 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?

----------
messages: 203270
nosy: haypo, rhettinger
priority: normal
severity: normal
status: open
title: Drop _source attribute of namedtuple
versions: Python 3.4

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


More information about the New-bugs-announce mailing list