[pypy-svn] r56426 - pypy/dist/pypy/module/itertools
cfbolz at codespeak.net
cfbolz at codespeak.net
Thu Jul 10 23:48:03 CEST 2008
Author: cfbolz
Date: Thu Jul 10 23:48:02 2008
New Revision: 56426
Modified:
pypy/dist/pypy/module/itertools/interp_itertools.py
Log:
Use a flag instead of a method. No code duplication and no method call.
Modified: pypy/dist/pypy/module/itertools/interp_itertools.py
==============================================================================
--- pypy/dist/pypy/module/itertools/interp_itertools.py (original)
+++ pypy/dist/pypy/module/itertools/interp_itertools.py Thu Jul 10 23:48:02 2008
@@ -218,14 +218,14 @@
def next_w(self):
while True:
w_obj = self.space.next(self.iterable) # may raise w_StopIteration
- if self._call_predicate(w_obj):
+ w_pred = self.space.call_function(self.w_predicate, w_obj)
+ pred = self.space.is_true(w_pred)
+ if pred ^ self.reverse:
return w_obj
class W_IFilter(_IFilterBase):
-
- def _call_predicate(self, w_obj):
- return self.space.is_true(self.space.call_function(self.w_predicate, w_obj))
+ reverse = False
def W_IFilter___new__(space, w_subtype, w_predicate, w_iterable):
return space.wrap(W_IFilter(space, w_predicate, w_iterable))
@@ -250,9 +250,7 @@
""")
class W_IFilterFalse(_IFilterBase):
-
- def _call_predicate(self, w_obj):
- return not self.space.is_true(self.space.call_function(self.w_predicate, w_obj))
+ reverse = True
def W_IFilterFalse___new__(space, w_subtype, w_predicate, w_iterable):
return space.wrap(W_IFilterFalse(space, w_predicate, w_iterable))
More information about the Pypy-commit
mailing list