#186 closed enhancement (fixed)
[patch] Refactor django/core/meta.py to eliminate duplicate code
Reported by: | Owned by: | Adrian Holovaty | |
---|---|---|---|
Component: | Metasystem | Version: | |
Severity: | normal | Keywords: | |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
The function_get_list
and function_get_iterator
functions in django/core/meta.py
are identical except for their return type. I propose refactoring them by making function_get_list
into a simple wrapper around function_get_iterator
.
Attachments (1)
Change History (4)
by , 19 years ago
Attachment: | refactor-function-get-list.patch added |
---|
comment:1 by , 19 years ago
The only difference between these two functions is that get_iterator calls cursor.fetchmany() at least once, and multiple times if necessary, until all rows have been returned; whereas get_list calls cursor.fetchall() exactly once.
If there is a database where fetchmany() incurs a significant performance penalty versus fetchall(), then it would be worth having two separate functions. But as it is, I see no benefit to the code duplication here.
comment:2 by , 19 years ago
Summary: | Refactor django/core/meta.py to eliminate duplicate code → [patch] Refactor django/core/meta.py to eliminate duplicate code |
---|
comment:3 by , 19 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Proposed patch to refactor function_get_list