Users of namedtuple: do you use the _source attribute?
Cameron Simpson
cs at zip.com.au
Tue Jul 18 00:55:12 EDT 2017
On 18Jul2017 02:57, Steve D'Aprano <steve+python at pearwood.info> wrote:
>collections.namedtuple generates a new class using exec, and records the source
>code for the class as a _source attribute.
>
>Although it has a leading underscore, it is actually a public attribute. The
>leading underscore distinguishes it from a named field potentially
>called "source", e.g. namedtuple("klass", ['source', 'destination']).
>
>There is some discussion on Python-Dev about:
>- changing the way the namedtuple class is generated which may
> change the _source attribute
>- or even dropping it altogether
>in order to speed up namedtuple and reduce Python's startup time.
>
>Is there anyone here who uses the namedtuple _source attribute?
Speaking for myself: no I do not.
Cheers,
Cameron Simpson <cs at zip.com.au>
More information about the Python-list
mailing list