News for hackers. Stuff that matters.
Re:Records: Python library for making raw SQL queries to Pos... by pyre on Sunday February 07, 2016 @03:27PM (#11054645)
namedtuple is just a thin wrapper around tuple. It literally constructs a class definition that sub-classes tuple as a string and then executes it. You can see the string template that it uses here[1]. If you're interested in something like namedtuple there are other[2] things[3] you can use depending on your use-case.

[1] https://github.com/python/cpython/blob/master/Lib/collection...

[2] http://stackoverflow.com/a/2648186

[3] https://pypi.python.org/pypi/frozendict/

Re:Records: Python library for making raw SQL queries to Pos... by Redoubts on Sunday February 07, 2016 @09:21PM (#11056066)
It's really weird that immutable tuples take a performance hit, compared to mutable lists (almost 50% on access!?!).
Re:Records: Python library for making raw SQL queries to Pos... by pyre on Monday February 08, 2016 @01:02AM (#11056570)
That's because Python 2 has a special case for lists[1]. This does not exist in Python 3[2] (and therefore neither does the performance difference).

[1] https://github.com/python/cpython/blob/2.7/Python/ceval.c#L1...

[2] https://github.com/python/cpython/blob/master/Python/ceval.c...

Re:Records: Python library for making raw SQL queries to Pos... by Redoubts on Monday February 08, 2016 @12:57PM (#11059674)
It looks like list access got slower as a result though.