Re:Let's Write an LLVM Specializer for Python
by dalke on Thursday January 22, 2015 @08:19PM
(#8932890)
[ Parent
| on HN ]
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.