Keep in mind that the normal path for an interned-string-key dict lookup in 2.2 is just this, where PyString_CheckExact succeeds, and assuming the key is present: register unsigned int mask = mp->ma_mask; dictentry *ep0 = mp->ma_table; register dictentry *ep; if (!PyString_CheckExact(key)) { mp->ma_lookup = lookdict; return lookdict(mp, key, hash); } i = hash & mask; ep = &ep0[i]; if (ep->me_key == NULL || ep->me_key == key) return ep; (Hmm -- the tests in that last "if" should check the second part first.) So there's usually not much to be saved by caching the index. The main benefit from Python's local-vrbl optimization has more to do with saving function calls than dict lookups (the latter are usually very cheap for interned string keys that are present).
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4