Hacker News
new
|
past
|
comments
|
ask
|
show
|
jobs
|
submit
login
sago
on Aug 20, 2016
|
parent
|
context
|
favorite
| on:
Python Lists vs. Tuples
First para: I think maybe you're confusing 'class' with inheritance from 'object'. A good tip is to do:
class Foo(namedtuple('Foo', (...)): def __repr__(self): ...
Your 'Foo' gets ordering, hashing, comparison, because it derives from 'namedtuple'. It gets '__repr__' too, but in the example I'm overriding that.
throwaway274739
on Aug 20, 2016
[–]
I would also add
__slots__ = ()
to your class definition so that instances of Foo keep the small memory footprint benefits do namedtuple.
Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4
Guidelines
|
FAQ
|
Lists
|
API
|
Security
|
Legal
|
Apply to YC
|
Contact
Search: