Opened 9 years ago

Closed 9 years ago

#4040 closed (fixed)

make use of in instead of has_key()

Reported by: Gary Wilson <gary.wilson@…> Owned by: adrian
Component: Core (Other) Version: master
Severity: Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


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

Attachments (1)

4040.diff (39.0 KB) - added by Gary Wilson <gary.wilson@…> 9 years ago.
replaced most has_key()'s with in

Download all attachments as: .zip

Change History (6)

Changed 9 years ago by Gary Wilson <gary.wilson@…>

replaced most has_key()'s with in

comment:1 Changed 9 years ago by Gary Wilson <gary.wilson@…>

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Design decision needed

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.

comment:2 Changed 9 years ago by Simon G. <dev@…>

  • Triage 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.

comment:3 Changed 9 years ago by mtredinnick

  • Triage 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.

comment:4 Changed 9 years ago by Gary Wilson <gary.wilson@…>

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).

comment:5 Changed 9 years ago by mtredinnick

  • Resolution set to fixed
  • Status changed from new to closed

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

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