1. Abstract

The namedtuplex package provides extended named tuples with additional features including an abstract base class, standard and extended class factories with function-style default values and additional parameters.

_images/structure.png

Figure: Class Diagram of namedtuples zoom more…

The best application is for return values as tuples with a variable number of valid members. The provided namedtuplex class fabric could be used as a drop-in replacement of the standard namedtuple [namedtuple].

The current release supports:

  • ineritance:

    Inheritance of abstract and non-abstract classes.

  • mixin:

    The use of the generated tuple class as mixin.

  • symbolic fieldnames

    Alternative symbolic names for the fields of the tuple, see also [namedtuple].

  • default values

    Default values for the fields, supports partial fields for the initialization of the generated class - similar to function arguments [PYFUNC].

  • attributes:

    Additional non-field attributes for the created tuple including default values.

  • abstract tuple classes

    Creates an abstract tuple class in accordance to [PEP3119], see also [abc]

  • performance impact

    The performance impact of the created named tuple class is compared to the collections.namedtuple none, compared to the standard tuple negligible. The created named tuple class actually uses the tuple as it’s base class, where the add-ons are performed for the customized creation only.

For an overview with additional details refer to the following section Blueprint.

For the extended namedtupledefs.namedtuple with fielddefaults see [namedtupledefs]. For the standard library collections.namedtuple see Python documentation [NAMEDTUPLEABCREF]. For the fast enumeration of the Python implementation and release refer to [pythonids].