aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Friedrich Bolz-Tereick <cfbolz@gmx.de>2019-10-01 21:02:02 +0200
committerCarl Friedrich Bolz-Tereick <cfbolz@gmx.de>2019-10-01 21:02:02 +0200
commit2bc99e4eda80601dca80910e000c54e98ac1c3bb (patch)
tree543e1155855871e269353ec90f66d90c343b9ba8 /pypy/objspace/std
parentremove now unused import (diff)
downloadpypy-2bc99e4eda80601dca80910e000c54e98ac1c3bb.tar.gz
pypy-2bc99e4eda80601dca80910e000c54e98ac1c3bb.tar.bz2
pypy-2bc99e4eda80601dca80910e000c54e98ac1c3bb.zip
don't turn ord(u) and u.islower() etc into bridges
Diffstat (limited to 'pypy/objspace/std')
-rw-r--r--pypy/objspace/std/unicodeobject.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/pypy/objspace/std/unicodeobject.py b/pypy/objspace/std/unicodeobject.py
index 31baf5e2cd..29161bdad0 100644
--- a/pypy/objspace/std/unicodeobject.py
+++ b/pypy/objspace/std/unicodeobject.py
@@ -41,6 +41,10 @@ def next_codepoint_pos_dont_look_inside(utf8, p):
def prev_codepoint_pos_dont_look_inside(utf8, p):
return rutf8.prev_codepoint_pos(utf8, p)
+@jit.elidable
+def codepoint_at_pos_dont_look_inside(utf8, p):
+ return rutf8.codepoint_at_pos(utf8, p)
+
class W_UnicodeObject(W_Root):
import_from_mixin(StringMethods)
@@ -134,7 +138,7 @@ class W_UnicodeObject(W_Root):
raise oefmt(space.w_TypeError,
"ord() expected a character, but string of length %d "
"found", self._len())
- return space.newint(rutf8.codepoint_at_pos(self._utf8, 0))
+ return space.newint(self.codepoint_at_pos_dont_look_inside(0))
def _empty(self):
return W_UnicodeObject.EMPTY
@@ -432,7 +436,7 @@ class W_UnicodeObject(W_Root):
if self._length == 0:
return space.w_False
if self._length == 1:
- return space.newbool(func(rutf8.codepoint_at_pos(self._utf8, 0)))
+ return space.newbool(func(self.codepoint_at_pos_dont_look_inside(0)))
else:
return self._is_generic_loop(space, self._utf8, func_name)
@@ -977,6 +981,11 @@ class W_UnicodeObject(W_Root):
return pos - 1
return prev_codepoint_pos_dont_look_inside(self._utf8, pos)
+ def codepoint_at_pos_dont_look_inside(self, pos):
+ if self.is_ascii():
+ return ord(self._utf8[pos])
+ return codepoint_at_pos_dont_look_inside(self._utf8, pos)
+
@always_inline
def _unwrap_and_search(self, space, w_sub, w_start, w_end, forward=True):
w_sub = self.convert_arg_to_w_unicode(space, w_sub)