Live data from Hacker News

Show HN: Python-to-Python compiler for some 3.6 features in older versions

github.com

91–100 of 113 posts

Re: Show HN: Python-to-Python compiler for some 3.6 features in older versions

#91

Earlier quoted context omitted.

Because Python 2.7 is, IMO, a better language than Python 3+, e.g.: - I like lambda a, b: a + b syntax better than lambda a_b: a_b[0] + a_b[1] - I prefer map/reduce/filter to return lists rather than iterable - I prefer dict.keys/values/items to return sets/lists rather than iterables, unless I call dict.iter[keys/values/items]

Iterables are so much better on memory though. I wonder why isn't "lambda (a, b): a+b" allowed?

[deleted]

Re: Show HN: Python-to-Python compiler for some 3.6 features in older versions

#92
post #13
post #11

Earlier quoted context omitted.

But isn't that what this is? I was under the impression that a compiler turns source code into machine code whereas a transpiler turns source code into differnet source code?

All compilers turn one form of code into another. Whether that's C to assembly (to machine code), or JavaScript to bytecode to machine code, or Python to Python. Transpiler is just a term referring to a compiler taking one high-level language to another. It's unnecessary because a Coffeescript to JavaScript compiler is a transpiler already; saying "transpiler" there tells you nothing you don't already know.

The phrase "an A to B compiler" might not gain anything from changing compiler to transpiler, but the phrase "an A compiler" does.

Re: Show HN: Python-to-Python compiler for some 3.6 features in older versions

#93
post #89
post #83

Earlier quoted context omitted.

That is why I used sys.hexversion. Since there are 3 paths, has real bytes, fake str bytes, and no bytes.

bytes exists since Python 2.6. Do you really need to support anything older?

Maybe not, but the incremental work was less than making a single codebase work for both 2 and 3. It's code that runs on openwrt, so forcing my ideas on the users is painful for them...they would have to build a whole new image.

Re: Show HN: Python-to-Python compiler for some 3.6 features in older versions

#95

Please don't. The transpiler route ended very badly for JS. Let's not open this pandora box for Python.

We've already had tools like 2to3, but they weren't all that popular, and this won't be either. Most things are ported to Python 3 now and most new projects just use Python 3. Never fear.

Re: Show HN: Python-to-Python compiler for some 3.6 features in older versions

#96

Earlier quoted context omitted.

Because it's going to be stable for the next N years. Python 2 is like FORTRAN. It might not be sexy anymore but it's not going anywhere.

> Python 2 is like FORTRAN. It might not be sexy anymore but it's not going anywhere. Except Fortran is, and is going to be, further developed. (So, if a new useful programming concept appears, or a major design mistake is discovered, it always can be patched.) Python 2 is going to be abandoned in 2020. Python 3 will supersede it.

FORTRAN 77 is just as likely to be abandoned in 2020 as well. And?

Re: Show HN: Python-to-Python compiler for some 3.6 features in older versions

#97
post #77

Earlier quoted context omitted.

> Because Python 3.X is not backwards compatible and we have millions of lines of production code in Python 2.X. I believe the common subset of Python 2 and 3 was created to ease that transition.

That common subset doesn't include string handling.

You can absolutely do string handling in a common subset of Python 2 and Python 3. It won't work for legacy string handling code if you relied on implicit coercion, but then the same apps are unlikely to support unicode either.

Re: Show HN: Python-to-Python compiler for some 3.6 features in older versions

#98
post #49

Earlier quoted context omitted.

Asking this question without disqualifying the answer "No breaking changes whatsoever" usually just generates a bunch of different ways of phrasing that.

No, I don't buy that. IBM successfully transitioned a huge customer base from 709/7090 36-bit words to System 360 32 bit words. The transition from 32 to 64 bit addresses was rocky for a lot of architectures. DEC Alpha, Intel Itanium. But are you still running a 32 bit OS? K&R C no longer compiles. Not that the C to C++14 transition is what I would call an example of greatness, but it is somewhere along the success s…

>K&R C no longer compiles.

    foo@virt-ubuntu:~/c$ gcc --version
    gcc (Ubuntu 6.3.0-12ubuntu2) 6.3.0 20170406
    Copyright (C) 2016 Free Software Foundation, Inc.
    This is free software; see the source for copying conditions.  There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    
    foo@virt-ubuntu:~/c$ cat 'k&r.c' 
    #include
    
    int main(argc, argv)
        int argc;
        char *argv[];
    {
        puts("hello, world!");
        return 0;
    }
    
    foo@virt-ubuntu:~/c$ gcc 'k&r.c' 
    foo@virt-ubuntu:~/c$ ./a.out
    hello, world!

Re: Show HN: Python-to-Python compiler for some 3.6 features in older versions

#99
post #96

Earlier quoted context omitted.

> Python 2 is like FORTRAN. It might not be sexy anymore but it's not going anywhere. Except Fortran is, and is going to be, further developed. (So, if a new useful programming concept appears, or a major design mistake is discovered, it always can be patched.) Python 2 is going to be abandoned in 2020. Python 3 will supersede it.

FORTRAN 77 is just as likely to be abandoned in 2020 as well. And?

How many uses can you find for Fortran 77 besides legacy systems?

Re: Show HN: Python-to-Python compiler for some 3.6 features in older versions

#100

Earlier quoted context omitted.

Because it's going to be stable for the next N years. Python 2 is like FORTRAN. It might not be sexy anymore but it's not going anywhere.

> Python 2 is like FORTRAN. It might not be sexy anymore but it's not going anywhere. Except Fortran is, and is going to be, further developed. (So, if a new useful programming concept appears, or a major design mistake is discovered, it always can be patched.) Python 2 is going to be abandoned in 2020. Python 3 will supersede it.

Abandoned by whom? ;-) I don't plan to abandon it.

Elsewhere in the thread xrange has mentioned Tauthon. And there are more Python 2 interpreters than just the main C Python.

Pypy may stop supporting 2 syntax officially, but I doubt it. Since it never changes, there's next to no overhead to keeping it available.

And further, if your language isn't changing then maintenance and debugging become much easier. Conceivably the codebase(s) can asymptotically approach 100% correctness.

O_o

Post reply on HN