3 ms·
Often I discover projects that are still in v2, and no words about v3 on their roadmap. Maybe v4 should learn from JavaScript5 and Visual Basic 3-6. Support v
by frik 11y ago
Often I discover projects that are still in v2, and no words about v3 on their roadmap.
Maybe v4 should learn from JavaScript5 and Visual Basic 3-6.
Support v2 syntax out of the box using a (slow) shim layer if there is no
"use strict"
in the first line. If that statement is present, don't load the shim layer and support only v4 syntax (faster).
That way old v2 code would still work without any changes.
- herge 11y agoThe syntax changes introduced in python 3 are easy to fix, and most of them are backwards compatible with python 2.7. The whole string/byte dichotomy, however, is a major change that I don't think any shim layer could handle correctly without major bugs, short of defining a whole new string-like class.
- frik 11y agoThe shim layer would have to convert all strings from v2 representation every time to the v4 implementation. Slower, but at least v2 could run unchanged. As we all know certain code won't be touched for whatever reason. It could certainly prevent some from deciding to move off to other languages like Go, Elixir, Node.
- herge 11y agoYour shim layer would have to make assumptions on the encoding of your strings, which can lead to nasty bugs. And also handle reading from files correctly, or list file names from the os, or anything that communicates outside of the python interpreter. The main reason why python 3 was created was to manage these complexities, and even then some people[1] say it wasn't done properly. [1] http://lucumr.pocoo.org/2014/5/12/everything-about-unicode/ http://lucumr.pocoo.org/2014/5/12/everything-about-unicode/