Show More
@@ -210,7 +210,10 b' except TypeError:' | |||||
210 | Python 2.3's eval. |
|
210 | Python 2.3's eval. | |
211 | """ |
|
211 | """ | |
212 |
|
212 | |||
213 | code = compile(codestring, "_eval", "eval") |
|
213 | if isinstance(codestring, basestring): | |
|
214 | code = compile(codestring, "_eval", "eval") | |||
|
215 | else: | |||
|
216 | code = codestring | |||
214 | newlocals = {} |
|
217 | newlocals = {} | |
215 | for name in code.co_names: |
|
218 | for name in code.co_names: | |
216 | try: |
|
219 | try: | |
@@ -1361,12 +1364,12 b' class ifilter(Pipe):' | |||||
1361 |
|
1364 | |||
1362 | def __xiter__(self, mode): |
|
1365 | def __xiter__(self, mode): | |
1363 | if callable(self.expr): |
|
1366 | if callable(self.expr): | |
1364 |
|
|
1367 | test = self.expr | |
1365 | return self.expr(item) |
|
|||
1366 | else: |
|
1368 | else: | |
1367 | g = getglobals(self.globals) |
|
1369 | g = getglobals(self.globals) | |
|
1370 | expr = compile(self.expr, "ipipe-expression", "eval") | |||
1368 | def test(item): |
|
1371 | def test(item): | |
1369 |
return eval( |
|
1372 | return eval(expr, g, AttrNamespace(item)) | |
1370 |
|
1373 | |||
1371 | ok = 0 |
|
1374 | ok = 0 | |
1372 | exc_info = None |
|
1375 | exc_info = None | |
@@ -1434,12 +1437,12 b' class ieval(Pipe):' | |||||
1434 |
|
1437 | |||
1435 | def __xiter__(self, mode): |
|
1438 | def __xiter__(self, mode): | |
1436 | if callable(self.expr): |
|
1439 | if callable(self.expr): | |
1437 |
d |
|
1440 | do = self.expr | |
1438 | return self.expr(item) |
|
|||
1439 | else: |
|
1441 | else: | |
1440 | g = getglobals(self.globals) |
|
1442 | g = getglobals(self.globals) | |
|
1443 | expr = compile(self.expr, "ipipe-expression", "eval") | |||
1441 | def do(item): |
|
1444 | def do(item): | |
1442 |
return eval( |
|
1445 | return eval(expr, g, AttrNamespace(item)) | |
1443 |
|
1446 | |||
1444 | ok = 0 |
|
1447 | ok = 0 | |
1445 | exc_info = None |
|
1448 | exc_info = None | |
@@ -1527,11 +1530,12 b' class isort(Pipe):' | |||||
1527 | ) |
|
1530 | ) | |
1528 | else: |
|
1531 | else: | |
1529 | g = getglobals(self.globals) |
|
1532 | g = getglobals(self.globals) | |
1530 | def key(item): |
|
1533 | key = compile(self.key, "ipipe-expression", "eval") | |
1531 | return eval(self.key, g, AttrNamespace(item)) |
|
1534 | def realkey(item): | |
|
1535 | return eval(key, g, AttrNamespace(item)) | |||
1532 | items = sorted( |
|
1536 | items = sorted( | |
1533 | xiter(self.input, mode), |
|
1537 | xiter(self.input, mode), | |
1534 | key=key, |
|
1538 | key=realkey, | |
1535 | reverse=self.reverse |
|
1539 | reverse=self.reverse | |
1536 | ) |
|
1540 | ) | |
1537 | for item in items: |
|
1541 | for item in items: |
@@ -1,3 +1,9 b'' | |||||
|
1 | 2006-07-12 Walter Doerwald <walter@livinglogic.de> | |||
|
2 | ||||
|
3 | * IPython/Extensions/ipipe.py (eval, ifilter, isort, ieval): | |||
|
4 | Compile expression strings into code objects. This should speed | |||
|
5 | up ifilter and friends somewhat. | |||
|
6 | ||||
1 | 2006-07-08 Ville Vainio <vivainio@gmail.com> |
|
7 | 2006-07-08 Ville Vainio <vivainio@gmail.com> | |
2 |
|
8 | |||
3 | * Magic.py: %cpaste now strips > from the beginning of lines |
|
9 | * Magic.py: %cpaste now strips > from the beginning of lines |
General Comments 0
You need to be logged in to leave comments.
Login now