Opened 14 years ago
Closed 14 years ago
#17644 closed Cleanup/optimization (fixed)
Use namedtuples in Query.alias_map to make debugging easier
| Reported by: | Łukasz Rekucki | Owned by: | Adrian Holovaty |
|---|---|---|---|
| Component: | Database layer (models, ORM) | Version: | 1.3 |
| Severity: | Normal | Keywords: | |
| Cc: | anssi.kaariainen@… | Triage Stage: | Accepted |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
Debugging the SQL compiler is not an easy task, and having to keep track of values in 8-tuples doesn't make it easier ;) There are probably more places that this could be applied to, not just alias_map, but it's a start. namedtuple has no extra memory or performance overhead (I didn't notice any change in the runtime of testsuite).
On Python 2.5, we just use a plain tuple (lookup code hasn't been changed so it just works).
Attachments (2)
Change History (8)
by , 14 years ago
| Attachment: | ticket17644.diff added |
|---|
comment:1 by , 14 years ago
| Has patch: | set |
|---|---|
| Owner: | changed from to |
comment:2 by , 14 years ago
| Triage Stage: | Unreviewed → Accepted |
|---|
comment:3 by , 14 years ago
| Cc: | added |
|---|
The attached patch converts alias_map values from ordinary tuples to namedtuples. All tests passed (although I can't test geodjango currently). No speed regressions spotted using djangobench. The first attached patch contains some comments which would be useful to consolidate into this patch.
by , 14 years ago
| Attachment: | ticket_17644.diff added |
|---|
comment:6 by , 14 years ago
| Resolution: | → fixed |
|---|---|
| Status: | assigned → closed |
I'd much prefer waiting until we can use namedtuple comprehensively, and take advantage of the attribute syntax for items, so I'd rather wait for 1.5 to do this.