Opened 18 years ago
Closed 18 years ago
#3438 closed (fixed)
django.db.models.base.__init__ refactoring
Reported by: | (removed) | Owned by: | Adrian Holovaty |
---|---|---|---|
Component: | Core (Other) | Version: | dev |
Severity: | Keywords: | ||
Cc: | Triage Stage: | Unreviewed | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Short version; for iteration over records, there model's init is rather unfriendly to the way the args are passed in.
At least for sqlite, the sql row is passed in as args- issue is that init shoots through self._model.fields playing with kwargs prior, doing rather costly exception catching, pulling default values, etc, then *finally* does args processing.
If you're dealing in one or two records, this doesn't show up much, but if you're dealing in 53k records (my usage is slightly weird admittedly), it's a pretty heavy slow down.
attached is a patch to refactor init, knocking around a third off the init cost via refactoring the args/kwargs processing, essentially reversing the actual flow while maintaining the same behaviour as before.
Have been using it for a few days, and passes tests; comments welcome, mainly since I need to get this integrated for my uses.
Attachments (1)
Change History (2)
by , 18 years ago
Attachment: | models-init.patch added |
---|
comment:1 by , 18 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
django.db.models.base.Model.init refactoring