4 ms·
Curious what the operations you're talking about are. Get?
by dangoldin 11y ago
Curious what the operations you're talking about are. Get?
- pyre 11y agoIf you look at the the StackOverflow in my sibling comment to yours, running 'obj.attrname' on a namedtuple takes longer because it needs to translate 'attrname' to an integer index and then run (e.g.) 'obj[0]'. Outside of that, I'm not sure.
- tveita 11y agoPickling, for one. >>> nt = namedtuple('nt', 'a b') >>> nt10k = [nt(1, 2) for i in range(10000)] >>> dict10k = [{'a':1, 'b':2} for i in range(10000)] >>> timeit pickle.dumps(nt10k) 10 loops, best of 3: 26.3 ms per loop >>> timeit pickle.dumps(dict10k) 100 loops, best of 3: 2.49 ms per loop