4 ms·
Is 15 years to prepare still not long enough to migrate your code incrementally? You can get Py2 into a nearly-ready-for-Py3 state with just a little effort str
by kevin_thibedeau 9y ago
Is 15 years to prepare still not long enough to migrate your code incrementally? You can get Py2 into a nearly-ready-for-Py3 state with just a little effort stretched over whatever horizon you desire. Beating a dead horse doesn't do anything about your stagnant code base.
- singularity2001 9y agoit's not about migrating old code bases, it's about encountering other peoples tensorflow/ubuntu code and often ending up in unnecessary(!) hickups.
- orf 9y agoI used to be quite militant about this, but you have to get that often business goals don't align. You can often do it on the side, during other changes, but convincing your manager that it's worth it is a hard problem.
- brylie 9y agoNP-hard.
- mjevans 9y agoNo, because they did a bunch of things that make automated porting not work well and provides a ton of developer friction. I'm willing to live with Python's space related insanity. Mandating that indenting is meaningful. Mandating a best practice of using spaces instead of tabs for indent* (which makes tab width matter). Mandating that a tab equals 4 spaces instead of 8. (Honestly, I REALLY hate this, most of the Windows developers are happy with the space usage koolaid, let us have a default of tab equals 8 spaces of indent.) Those are ALL, REALLY ANNOYING, but lint tools can save me. What will bite me for as long as Python 3 exists, and maybe Python 4, is how they handle Unicode support and encoded outputs. Pretty much the ENTIRE rest of the computing world does one of two things. 1) Doesn't care what the encoding is, and flings around non-validated 8 bit sequences of data. 2) Does care, and defaults to assuming well formed UTF-8 data-streams for text data, BUT still doesn't do anything to enforce it UNLESS ASKED. Most importantly invalid data streams just continue flowing through the processing tools until they reach a point where a human has designated they're willing to care and /do/ something about it. If Python 4 wants to 'fix' Unicode support: * Use a binary sequence base storage class with metadata tags. > Length (in bytes, in 'display length', and maybe in 'codepoint length') > encoding* (including if normalized and how so) > If the encoding has been validated. * Support automatic coercion between standard encodings * Allow user defined helpers for custom conversions * Make all input/output default to UTF-8** but permit raw output of such types without validation or re-encoding, just like every other UNIX tool that knows what an encoding is.
- singularity2001 9y agoYes, please make UTF-8 default! It's 2018 print(str(b'I DONT WANT TO add "UTF-8" everywhere!!','UTF-8'))
- ubernostrum 9y agoAs a serialization and transmission format, UTF-8 is fine. As the basis of a high-level language's string type, UTF-8 is objectively incorrect. Strings in a high-level language should be as clean an abstraction of Unicode as possible, and leaking implementation details of the particular byte-encoding scheme up to the programmer is not acceptable.
- singularity2001 9y agoOk, is it reasonable to ask for all string getter/setter file read/write ops to default to UTF-8? also having different string methods .byte_length .char_length(?) .codepoint_length seems a good idea. or string.length(aspect=bytes) but what should be the default aspect?
- mjevans 9y agoFor compatibility reasons, len(unicode type) should probably return the size if accessed as a raw 8 bit sequence, so an alias to .length_bytes. I also think the other names should similarly start with .length_ .
- mark-r 9y agolen() should return the length in individual addressable units, so that obj[len(obj)-1] always returns the last item, whether that's a byte or a unicode character.
- ubernostrum 9y agoI'm going to quote something I wrote a couple years ago[1]: Now, I should point out here that I’m not really knocking the people who were writing, say, command-line and file-handling utilities in Python. For years, Python sort of accepted the status quo of the Unix world, which was mostly to stick its fingers in its ears and shout LA LA LA I CAN’T HEAR YOU I’M JUST GOING TO SET LC_CTYPE TO C AGAIN AND GO BACK TO MY HAPPY PLACE. A bit later on it changed to “just use UTF-8 everywhere, UTF-8 is perfectly safe”, which really meant “just use UTF-8 everywhere because we can continue pretending it’s ASCII up until the time someone gives us a non-ASCII or multi-byte character, at which point do the fingers-in-ears-can’t-hear-you thing again”. So a lot of what you’ll see in terms of complaints about string handling are really complaints that Unix’s pretend-everything-is-ASCII-until-it-breaks approach was never very good to begin with and just gets worse with every passing year. I stand by this: we had a couple of decades of Python catering to this brokenness, and it made life miserable for everyone who didn't work in that particular domain. Python 3 changed that. Does it mean life got harder for some people? Yup. But life got a lot easier and more reliable for many more people, and it's a tradeoff I'm willing to accept. [1] https://www.b-list.org/weblog/2016/jun/10/python-3-again/ https://www.b-list.org/weblog/2016/jun/10/python-3-again/