Django

Code

Ticket #4040 (closed: fixed)

Opened 2 years ago

Last modified 2 years ago

make use of in instead of has_key()

Reported by: Gary Wilson <gary.wilson@gmail.com> Assigned to: adrian
Milestone: Component: Core framework
Version: SVN Keywords:
Cc: Triage Stage: Accepted
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

Description

has_key() is slower and will be going away in python3.

Attachments

4040.diff (39.0 kB) - added by Gary Wilson <gary.wilson@gmail.com> on 04/14/07 00:05:37.
replaced most has_key()'s with in

Change History

04/14/07 00:05:37 changed by Gary Wilson <gary.wilson@gmail.com>

  • attachment 4040.diff added.

replaced most has_key()'s with in

04/14/07 00:10:18 changed by Gary Wilson <gary.wilson@gmail.com>

  • needs_better_patch changed.
  • stage changed from Unreviewed to Design decision needed.
  • needs_tests changed.
  • needs_docs changed.

There are a couple has_key() calls in dispatcher package, but I wasn't sure if we are keeping that in sync with upstream or not. All tests passed for me, but I wouldn't be surprised if not all the changes are covered by a test.

04/14/07 02:10:01 changed by Simon G. <dev@simon.net.nz>

  • stage changed from Design decision needed to Ready for checkin.

I think this would be good to get in for future proofing reasons (and speed!). Shouldn't raise any bugs that I can think of.

04/20/07 04:53:53 changed by mtredinnick

  • stage changed from Ready for checkin to Accepted.

Does this depend on #4041 at all? It's not clear what the relationship is between this ticket and that one? Moving back to "accepted" until that is clarified.

This is pretty low priority, since the speed difference between the two versions is tiny for all practical purposes and Python 3000 doesn't exist yet (and will require more than one or two changes to our code). However, it's probably worth putting in at some point.

04/20/07 08:49:19 changed by Gary Wilson <gary.wilson@gmail.com>

This ticket is independent of #4041 since Django itself doesn't actually use the cache framework (except for in the tests, but there is no use of 'in' in the cache tests).

04/26/07 08:30:49 changed by mtredinnick

  • status changed from new to closed.
  • resolution set to fixed.

(In [5091]) Fixed #4040 -- Changed uses of has_key() to "in". Slight performance improvement and forward-compatible with future Python releases. Patch from Gary Wilson.


Add/Change #4040 (make use of in instead of has_key())




Change Properties
Action