- attached has_key_r3314.diff
[Patch] foo.has_key -> in foo
Attached is a patch to convert all has_key calls to 'in ' calls.
!contains! is the same as has_key on dicts (and hopefully on any dict like objects!), but has_key is slower as it incurs a !dict! lookup to grab the has_key method
this was applied to all files except:
doc/build/lib/markdown.py
test/testlib/coverage.py
This was an automated conversion. FYI, incase this patch isn't applied immediately (which might require it to be redone =[ ), the conversion made a couple bogus changes that had to be fixed by hand:
sqlalchemy.util: switch OrderedProperties.has_key back to calling self._data.has_key. for consistency's sake
sqlalchemy.sql: fix ColumnCollection.contains to return util.OrderedProperties.contains(self, other) instead of 'in self' (endless loop) or the original self.has_key (could use super here but I believe going to the class directly is faster)
sqlalchemy.orm.mapper: Change: if identitykey in context.session:
Back to: if context.session.has_key(identitykey):
Session.has_key is VERY different from Session.contains! (evil?)
sqlalchemy.orm.util: make TranslatingDict.contains do the actual lookup work instead of has_key. in that code, call super contains instead of 'in' (endless loop). has_key no longer does the work, instead calls 'in self'
Comments (3)
-
Account Deleted -
repo owner - changed status to resolved
patch went in great, all tests passed with SQLite (we'll see how the buildbot fares with mysql and postgres). will mark as fixed for now e02a48ed24ee4548e765c3b2a26e8f20d0d992e2. thanks !
-
repo owner - removed milestone
Removing milestone: 0.4.0 (automated comment)
- Log in to comment
patch against trunk r3314