Zaur Shibzukhov <[email protected]> added the comment:
Instead of using cache, maybe better to use mutable default argument?
For example:
def make_row_factory(cls_factory, **kw):
def row_factory(cursor, row, cls=[None]):
rf = cls[0]
if rf is None:
fields = [col[0] for col in cursor.description]
cls[0] = cls_factory("Row", fields, **kw)
return cls[0](*row)
return rf(*row)
return row_factory
namedtuple_row_factory = make_row_factory(namedtuple)
Seem it should add less overhead.
----------
nosy: +intellimath
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue13299>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com