Message398970
| Author |
intellimath |
| Recipients |
Russell.Sim, YoSTEALTH, dlenski, eric.araujo, erlendaasland, ghaering, intellimath, ncoghlan, petri.lehtinen, rhettinger, serhiy.storchaka |
| Date |
2021年08月05日.07:15:53 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1628147753.4.0.865582360645.issue13299@roundup.psfhosted.org> |
| In-reply-to |
| Content |
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. |
|
History
|
|---|
| Date |
User |
Action |
Args |
| 2021年08月05日 07:15:53 | intellimath | set | recipients:
+ intellimath, rhettinger, ghaering, ncoghlan, eric.araujo, petri.lehtinen, serhiy.storchaka, dlenski, Russell.Sim, YoSTEALTH, erlendaasland |
| 2021年08月05日 07:15:53 | intellimath | set | messageid: <1628147753.4.0.865582360645.issue13299@roundup.psfhosted.org> |
| 2021年08月05日 07:15:53 | intellimath | link | issue13299 messages |
| 2021年08月05日 07:15:53 | intellimath | create |
|