Re:Python Lists vs. Tuples
by sago on Friday August 19, 2016 @08:11PM
(#12324382)
First para: I think maybe you're confusing 'class' with inheritance from 'object'. A good tip is to do:
Your 'Foo' gets ordering, hashing, comparison, because it derives from 'namedtuple'. It gets '__repr__' too, but in the example I'm overriding that.
[ Parent
| on HN ]
Re:Python Lists vs. Tuples
by throwaway274739 on Saturday August 20, 2016 @05:58AM
(#12325903)
I would also add
__slots__ = ()
to your class definition so that instances of Foo keep the small memory footprint benefits do namedtuple.