Show More
@@ -210,7 +210,10 b' except TypeError:' | |||
|
210 | 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 | 217 | newlocals = {} |
|
215 | 218 | for name in code.co_names: |
|
216 | 219 | try: |
@@ -1361,12 +1364,12 b' class ifilter(Pipe):' | |||
|
1361 | 1364 | |
|
1362 | 1365 | def __xiter__(self, mode): |
|
1363 | 1366 | if callable(self.expr): |
|
1364 |
|
|
|
1365 | return self.expr(item) | |
|
1367 | test = self.expr | |
|
1366 | 1368 | else: |
|
1367 | 1369 | g = getglobals(self.globals) |
|
1370 | expr = compile(self.expr, "ipipe-expression", "eval") | |
|
1368 | 1371 | def test(item): |
|
1369 |
return eval( |
|
|
1372 | return eval(expr, g, AttrNamespace(item)) | |
|
1370 | 1373 | |
|
1371 | 1374 | ok = 0 |
|
1372 | 1375 | exc_info = None |
@@ -1434,12 +1437,12 b' class ieval(Pipe):' | |||
|
1434 | 1437 | |
|
1435 | 1438 | def __xiter__(self, mode): |
|
1436 | 1439 | if callable(self.expr): |
|
1437 |
d |
|
|
1438 | return self.expr(item) | |
|
1440 | do = self.expr | |
|
1439 | 1441 | else: |
|
1440 | 1442 | g = getglobals(self.globals) |
|
1443 | expr = compile(self.expr, "ipipe-expression", "eval") | |
|
1441 | 1444 | def do(item): |
|
1442 |
return eval( |
|
|
1445 | return eval(expr, g, AttrNamespace(item)) | |
|
1443 | 1446 | |
|
1444 | 1447 | ok = 0 |
|
1445 | 1448 | exc_info = None |
@@ -1527,11 +1530,12 b' class isort(Pipe):' | |||
|
1527 | 1530 | ) |
|
1528 | 1531 | else: |
|
1529 | 1532 | g = getglobals(self.globals) |
|
1530 | def key(item): | |
|
1531 | return eval(self.key, g, AttrNamespace(item)) | |
|
1533 | key = compile(self.key, "ipipe-expression", "eval") | |
|
1534 | def realkey(item): | |
|
1535 | return eval(key, g, AttrNamespace(item)) | |
|
1532 | 1536 | items = sorted( |
|
1533 | 1537 | xiter(self.input, mode), |
|
1534 | key=key, | |
|
1538 | key=realkey, | |
|
1535 | 1539 | reverse=self.reverse |
|
1536 | 1540 | ) |
|
1537 | 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 | 7 | 2006-07-08 Ville Vainio <vivainio@gmail.com> |
|
2 | 8 | |
|
3 | 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