[pypy-svn] r32892 - pypy/dist/pypy/module/_sre
fijal at codespeak.net
fijal at codespeak.net
Wed Oct 4 22:41:47 CEST 2006
Author: fijal
Date: Wed Oct 4 22:41:45 2006
New Revision: 32892
Modified:
pypy/dist/pypy/module/_sre/interp_sre.py
Log:
Fixed sre's performance by about 1/3. Still about 66x todo...
Modified: pypy/dist/pypy/module/_sre/interp_sre.py
==============================================================================
--- pypy/dist/pypy/module/_sre/interp_sre.py (original)
+++ pypy/dist/pypy/module/_sre/interp_sre.py Wed Oct 4 22:41:45 2006
@@ -160,12 +160,12 @@
MATCHED = 1
NOT_MATCHED = 2
- def __init__(self, space, state, pattern_codes):
+ def __init__(self, space, state, pattern_codes, offset=0):
self.space = space
self.state = state
self.pattern_codes = pattern_codes
self.string_position = state.string_position
- self.code_position = 0
+ self.code_position = offset
self.has_matched = self.UNDECIDED
self.backup = []
self.resume_at_opcode = -1
@@ -176,8 +176,8 @@
start interpreting from."""
offset = self.code_position + pattern_offset
assert offset >= 0
- pattern_codes = self.pattern_codes[offset:]
- child_context = MatchContext(self.space, self.state, pattern_codes)
+ #pattern_codes = self.pattern_codes[offset:]
+ child_context = MatchContext(self.space, self.state, self.pattern_codes, offset)
self.state.context_stack.append(child_context)
self.child_context = child_context
return child_context
@@ -241,7 +241,7 @@
offset = context.code_position
assert offset >= 0
MatchContext.__init__(self, space, context.state,
- context.pattern_codes[offset:])
+ context.pattern_codes, offset)
self.count = -1
self.previous = context.state.repeat
self.last_position = -1
@@ -266,7 +266,7 @@
flags = pattern_codes[2]
offset = pattern_codes[1] + 1
assert offset >= 0
- pattern_codes = pattern_codes[offset:]
+ #pattern_codes = pattern_codes[offset:]
string_position = state.start
while string_position <= state.end:
More information about the Pypy-commit
mailing list