[Python-Dev] r59947 - in python/trunk:Lib/test/test_structseq.py Misc/NEWS (original) (raw)

Raymond Hettinger python at rcn.com
Mon Jan 14 05:26:45 CET 2008


1. Have structseq subclass from PyTupleObject so that isinstance(s, tuple) returns True. This makes the object usable whenever tuples are needed. Hmm, is that really necessary? structseq has been in use for quite a while and this need hasn't come up -- it's been designed to be quite compatible with tuple except for isinstance checks, and that has worked well.

It looks like that is the only difference, so subclassing from tuple won't cause any other behavioral changes. It looks like making it a subtype involves only changing a few lines. I think it can only help, especially if we start to use structseq for more things in the future. Also, I would like the API to match collections.namedtuple() as closely as possible so that there is just a single useful concept that gets applied whereever needed. The idea is basically that they are tuples with the added nicity of attribute access and a self-documenting repr.

Raymond



More information about the Python-Dev mailing list