List comprehension seems to work differently on python 2.5.2 versus
jython2.5b0.
With python2.5 the attached program gives
---
1
[(1, (0, 1), (0, 1))]
---
whereas with jython2.5b0 it gives
---
6
[(1, (0, 1), (0, 1)), (8, (0, 2), (0, 1)), (27, (0, 3), (0, 1)), (9, (1,
2), (0, 1)), (28, (1, 3), (0, 1)), (35, (2, 3), (0, 1))]
---
obviously getting some if of computation wrong (works with jython2.2
though).
|
An AST bug. Here's the difference between py/jy ASTs:
--- py25 2008-12-15 22:00:48.000000000 -0800
+++ jy25 2008-12-15 22:01:01.000000000 -0800
@@ -89,39 +89,7 @@
('left', ('Name (2,125)', ('id', 'y1'), ('ctx', ('Load',)))),
('ops', ('Lt',)),
('comparators',
- ('Name (2,130)', ('id', 'y2'), ('ctx', ('Load',))))),
- ('Compare (2,136)',
- ('left',
- ('BinOp (2,136)',
- ('left',
- ('BinOp (2,136)',
- ('left',
- ('Name (2,136)', ('id', 'x1'), ('ctx', ('Load',)))),
- ('op', ('Pow',)),
- ('right', ('Num (2,140)', ('n', 3))))),
- ('op', ('Add',)),
- ('right',
- ('BinOp (2,142)',
- ('left',
- ('Name (2,142)', ('id', 'x2'), ('ctx', ('Load',)))),
- ('op', ('Pow',)),
- ('right', ('Num (2,146)', ('n', 3))))))),
- ('ops', ('Eq',)),
- ('comparators',
- ('BinOp (2,151)',
- ('left',
- ('BinOp (2,151)',
- ('left',
- ('Name (2,151)', ('id', 'y1'), ('ctx', ('Load',)))),
- ('op', ('Pow',)),
- ('right', ('Num (2,155)', ('n', 3))))),
- ('op', ('Add',)),
- ('right',
- ('BinOp (2,157)',
- ('left',
- ('Name (2,157)', ('id', 'y2'), ('ctx', ('Load',)))),
- ('op', ('Pow',)),
- ('right', ('Num (2,161)', ('n', 3)))))))))))))),
+ ('Name (2,130)', ('id', 'y2'), ('ctx', ('Load',))))))))))),
('Print (3,0)',
('dest', None),
('values',
Which means we didn't recognize the last if statement. i.e. we're
thinking it's this (CPython gives the result of len 6 with this):
l = [(x1**3+x2**3,(x1,x2),(y1,y2)) for x1 in range(4) for x2 in range(4)
if x1 < x2 for y1 in range(g) for y2 in range(g) if y1 < y2]
|