Re:Let's Write an LLVM Specializer for Python
by danohuiginn on Thursday January 22, 2015 @09:45AM
(#8929355)
Is that line really using any new features in Python 3? The lazy evaluation there is in the file object and the generator expression, both of which have long been present in python2.
[ Parent
| on HN ]
Re:Let's Write an LLVM Specializer for Python
by exDM69 on Thursday January 22, 2015 @09:53AM
(#8929395)
No, it wasn't. I added map(str.upper, xxx), now it does.
Re:Let's Write an LLVM Specializer for Python
by masklinn on Thursday January 22, 2015 @12:56PM
(#8930559)
Then again a lazy map is just an import away in P2. It removes pitfalls from Python but the improvement is⦠very limited (as opposed to e.g. `yield from` which is a big convenience, or for much more specialised uses the ellipsis literal being universal)
Re:Let's Write an LLVM Specializer for Python
by dalke on Thursday January 22, 2015 @08:19PM
(#8932890)
(process(line.upper()) for line in open('giantfile.txt') if line.lstrip()[0] != '#')
Re:Let's Write an LLVM Specializer for Python
by exDM69 on Friday January 23, 2015 @02:54AM
(#8933843)
That's besides the point. It's trivial to write that as a for loop or in a million different ways to avoid the issue. It's a contrived example written to demonstrate a difference.
Here's another one you can't change that easily:
tests_pass = all(process(input) == output for (input, output) in zip(open('inputs.txt'), open('outputs.txt'))
Re:Let's Write an LLVM Specializer for Python
by andreasvc on Friday January 23, 2015 @08:35AM
(#8934712)
You can change that easily, with izip from itertools.
The fact that a bunch of builtins and the values/items methods of dictionaries have become iterators is not very siginificant IMHO. Python 2 code could already be written to use iterators or generator expressions, so in the parts where it was crucial it was already done. In this regard Python 3 has not added new functionality but only changed defaults.
The unicode change is the big one.
Re:Let's Write an LLVM Specializer for Python
by dalke on Friday January 23, 2015 @03:33PM
(#8937093)
In this case (checking that process(input) == output), itertools.izip_longest is probably that right solution, unless there's an out-of-band way to know that inputs.txt is the same length as outputs.txt.