[pypy-commit] pypy default: split _codecs.lookup_codec into parts with and without a loop, so the JIT can inline most of lookup_codec, eventually it might even make sense to make this codec_search_cache thing be a purefunction, but I'm not sure what it's sematnics are ATM

alex_gaynor noreply at buildbot.pypy.org
Tue Jan 17 19:51:58 CET 2012


Author: Alex Gaynor <alex.gaynor at gmail.com>
Branch: 
Changeset: r51414:33bd443587ba
Date: 2012-01-17 12:51 -0600
http://bitbucket.org/pypy/pypy/changeset/33bd443587ba/

Log:	split _codecs.lookup_codec into parts with and without a loop, so
	the JIT can inline most of lookup_codec, eventually it might even
	make sense to make this codec_search_cache thing be a purefunction,
	but I'm not sure what it's sematnics are ATM

diff --git a/pypy/module/_codecs/interp_codecs.py b/pypy/module/_codecs/interp_codecs.py
--- a/pypy/module/_codecs/interp_codecs.py
+++ b/pypy/module/_codecs/interp_codecs.py
@@ -108,6 +108,10 @@
     w_result = state.codec_search_cache.get(normalized_encoding, None)
     if w_result is not None:
         return w_result
+    return _lookup_codec_loop(space, encoding, normalized_encoding)
+
+def _lookup_codec_loop(space, encoding, normalized_encoding):
+    state = space.fromcache(CodecState)
     if state.codec_need_encodings:
         w_import = space.getattr(space.builtin, space.wrap("__import__"))
         # registers new codecs


More information about the pypy-commit mailing list