|
|
Subscribe / Log in / New account

Pyston — a new Python 2.7 implementation

Pyston — a new Python 2.7 implementation

Posted Apr 5, 2014 9:38 UTC (Sat) by khim (subscriber, #9252)
In reply to: Pyston — a new Python 2.7 implementation by marcH
Parent article: Pyston — a new Python 2.7 implementation

It's just tedious. There are many small and subtle differences. For example you can create something (presumably some kind of byte sequence) both in Python2 and Python3 by invoking bytes([1,2,3]), but then for some strange reason bytes([1,2,3])[2] > 3 in True in Python2 but False in Python3 (guess why?).

You must always keep both Python2 and Python3 behavior when you are doing such things. If you are checking with python3 first then your code if often does some weird things in Python3 (Python3 is more logical of the two) and if you are checking with Python2 first then your code often just explodes in python3 and must be fixed. That's slightly easier but why bother?

If that's my own script then I can grab and install Python2 interprerer whereever I need it and if it's shared scripts then I need to regularly grab and check all the scripts in the project to make sure they still work with Python3. At some point I've just decided not to care. I could use Python3 for my own scripts and Python2 for shared scripts but why bother? Python2 works fine for both.


to post comments

Pyston — a new Python 2.7 implementation

Posted Apr 6, 2014 9:33 UTC (Sun) by job (guest, #670) [Link]

I've also tried this and found it tedious on the verge of unbearable.

Is there some utility that helps?

It would be great to be able to include a library that bombs the program if a line of code would not execute with identical result under Python 3, for example.

Pyston — a new Python 2.7 implementation

Posted Apr 6, 2014 17:11 UTC (Sun) by bluss (guest, #47454) [Link] (1 responses)

bytes is probably best to avoid if you are trying bicompatibility unfortunately. bytearray() is much better.

Pyston — a new Python 2.7 implementation

Posted Apr 6, 2014 18:19 UTC (Sun) by khim (subscriber, #9252) [Link]

Unfortunatelly bytearray is mutable which means that you can not use it as key. You can do something like bytes(bytearray([1,2,3])) which works but is ugly and means that programming starts to look more like puzzle solving and less like programming. I basically feel like I'm writing a Polyglot which is extremely irritating. I feel similarly when I need to write some header which must be compileable by C and C++ compilers—but there it's limited to headers, I can decide if I want to compile any file as C or C++ and can change the decision at any time. With python 2+3 you are forced to do that for the whole program. Thanks, but no, thanks.


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds