[pypy-commit] pypy unicode-utf8: fix more tests
cfbolz
pypy.commits at gmail.com
Fri Nov 24 08:00:47 EST 2017
Author: Carl Friedrich Bolz-Tereick <cfbolz at gmx.de>
Branch: unicode-utf8
Changeset: r93160:a9bb96fbf9d4
Date: 2017-11-24 13:53 +0100
http://bitbucket.org/pypy/pypy/changeset/a9bb96fbf9d4/
Log: fix more tests
BUT: a slight pessimization, because object decoding becomes a
little bit slower
diff --git a/pypy/module/_pypyjson/interp_decoder.py b/pypy/module/_pypyjson/interp_decoder.py
--- a/pypy/module/_pypyjson/interp_decoder.py
+++ b/pypy/module/_pypyjson/interp_decoder.py
@@ -247,10 +247,11 @@
self.pos = i+1
return self.space.newdict()
- d = {}
+ # XXX this should be improved to use an unwrapped dict
+ w_dict = self.space.newdict()
while True:
# parse a key: value
- name = self.decode_key(i)
+ w_name = self.decode_key(i)
i = self.skip_whitespace(self.pos)
ch = self.ll_chars[i]
if ch != ':':
@@ -259,13 +260,13 @@
i = self.skip_whitespace(i)
#
w_value = self.decode_any(i)
- d[name] = w_value
+ self.space.setitem(w_dict, w_name, w_value)
i = self.skip_whitespace(self.pos)
ch = self.ll_chars[i]
i += 1
if ch == '}':
self.pos = i
- return self._create_dict(d)
+ return w_dict
elif ch == ',':
pass
elif ch == '\0':
@@ -274,10 +275,6 @@
self._raise("Unexpected '%s' when decoding object (char %d)",
ch, i-1)
- def _create_dict(self, d):
- from pypy.objspace.std.dictmultiobject import from_unicode_key_dict
- return from_unicode_key_dict(self.space, d)
-
def decode_string(self, i):
start = i
bits = 0
@@ -383,7 +380,7 @@
return 0x10000 + (((highsurr - 0xd800) << 10) | (lowsurr - 0xdc00))
def decode_key(self, i):
- """ returns an unwrapped unicode """
+ """ returns a wrapped unicode """
from rpython.rlib.rarithmetic import intmask
i = self.skip_whitespace(i)
diff --git a/pypy/objspace/std/dictmultiobject.py b/pypy/objspace/std/dictmultiobject.py
--- a/pypy/objspace/std/dictmultiobject.py
+++ b/pypy/objspace/std/dictmultiobject.py
@@ -1257,12 +1257,6 @@
create_iterator_classes(UnicodeDictStrategy)
-def from_unicode_key_dict(space, d):
- strategy = space.fromcache(UnicodeDictStrategy)
- storage = strategy.erase(d)
- return W_DictObject(space, strategy, storage)
-
-
class IntDictStrategy(AbstractTypedStrategy, DictStrategy):
erase, unerase = rerased.new_erasing_pair("int")
erase = staticmethod(erase)
More information about the pypy-commit
mailing list