Opened 11 years ago

Closed 11 years ago

Last modified 9 years ago

#186 closed enhancement (fixed)

[patch] Refactor django/core/meta.py to eliminate duplicate code

Reported by: rmunn@… 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: UI/UX:

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)

refactor-function-get-list.patch (1.6 KB) - added by rmunn@… 11 years ago.
Proposed patch to refactor function_get_list

Download all attachments as: .zip

Change History (4)

Changed 11 years ago by rmunn@…

Proposed patch to refactor function_get_list

comment:1 Changed 11 years ago by rmunn@…

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 Changed 11 years ago by rmunn@…

Summary: Refactor django/core/meta.py to eliminate duplicate code[patch] Refactor django/core/meta.py to eliminate duplicate code

comment:3 Changed 11 years ago by Adrian Holovaty

Resolution: fixed
Status: newclosed

(In [329]) Fixed #186 -- Refactored meta.py to remove duplicate code between function_get_list and function_get_iterator. Thanks, rmunn@…

Note: See TracTickets for help on using tickets.
Back to Top