[Python-ideas] Add recordlcass to collections module

Jonathan Fine jfine2358 at gmail.com
Sat Sep 1 12:10:49 EDT 2018

Hi Martin

Summary: Thank you. Your suggestion has good points. I suggest to
advance it (i) provide a pure Python implementation of namedlist, and
(ii) ask that the Python docs for namedtuple provide a link to

Thank you, Martin, for bringing
https://bitbucket.org/intellimath/recordclass to this list's
attention. Here's my first impressions.

Here's the good things I've noticed (although not closely examined).

1. This is released software, available through pip.
2. There's a link on the page to an example in a Jupyter notebook.
3. That page gives performance statistics for the C-implementation.
4. The key idea is simple and well expressed.
5. The promoter (you) is not the package's author.

Of all the suggestions made to this list, I'd say based on the above
that this one is in the top quarter. The credit for this belong
mostly, of course its author Zaur Shibzukhov. By the way, there's a
mirror of the bitbucket repository here

Here's my suggestions for going forward. They're based on my guess
that there's some need for a mutable variant of named tuple, but not
the same need for a C implementation. And they're based on what I
like, rather than the opinions of many.

1. Produce a pure Python implementation of recordclass.

2. Instead, as you said, call it namedlist.

3. Write some docs for the new class, similar to

4. Once you've done 1-3 above, request that the Python docs reference
the new class in the "See also" for named tuple.

Mutable and immutable is, for me, a key concept in Python. Here's an
easy way to 'modify' a tuple:

>>> orig = tuple(range(5)); orig
(0, 1, 2, 3, 4)
>>> tmp = list(orig)
>>> tmp = list(orig); tmp
[0, 1, 2, 3, 4]
>>> tmp[3] += tmp[1]; tmp[4] += tmp[2]
>>> tmp
[0, 1, 2, 4, 6]
>>> result = tuple(tmp); result
(0, 1, 2, 4, 6)

Of course, 'modify' means create a new one, changed in some way. And
if the original is a namedtuple, that it makes sense to use namedlist.

Here are some final remarks. (All my own opinions, not deep truth.)

1. Focus on getting and meeting the expressed needs of users. A link
from the Python docs will help here.

2. Don't worry about performance of the pure Python implementation. It
won't hold back progress.

3. I'd personally like to see something like numpy, but for
combinatorial rather than numerical computing. Perhaps the
memoryslots.c (on which recordclass depends) might be useful here. But
that's further in the future.

Once again, thank you for Martin, for bringing this to our attention.
And to Zaur for writing the software.

best regards


More information about the Python-ideas mailing list