4 ms·
SQLAlchemy creator here. No single improvement in Python has made my life more dramatically easier than the introduction and standardization of strings as Unic
by zzzeek 4y ago
SQLAlchemy creator here.
No single improvement in Python has made my life more dramatically easier than the introduction and standardization of strings as Unicode. The basic reason is because it clearly placed the burden of encoding / decoding on the *outside* edges of a program; right when data is coming in, or right when data is going out. If you want the world to consider the data between those to be a "a string", you have to do that for us.
For me, it meant that every PEP-249 DBAPI finally took on the role of handling database encodings fully and completely. Enormous reams of arbitrary string encode/decode logic in SQLAlchemy, having to guess its way around all the different decisions every DBAPI made about this, gone. If I get a string from the DBAPI, it's decoded. If I have a string, I can send it out, DBAPI handles it. If it contains characters that aren't appropriate for the database's encoding, it raises. Great! I send the users off to the manual for their database, they aren't complaining to me. Total lifesaver.
I see a lot of odd complaints here which seem to be people wanting non-textual bytestrings to do things that make sense for text; if someone has a use case like that, there can be libraries that do the particular non-textual-but-text-like manipulations they need, however, these are not the "standard" uses for textual strings in Python. The standard use for textual strings is...to represent text! If I have data that's bytes, then I use bytes! These threads always seem to fill up with the vanishingly small number of people that have issues with this. Just like the anti-ORM threads. All the while the vast majority of devs are just getting work done.
- Alir3z4 4y agoUnicode errors were one the most painful and annoying issues I had. Regardless of working with xml files, parsing text or just dealing with anything text related. When upgrading to Python 3, they just vanished. Anti ORM people probably don't know what ORM is or confused about their usage and benefit they bring. Once you're dealing with several tables and relations and lots of aggregation and annotations, raw sql is the one way ticket to insanity. By the way, thank you very much for making SQLAlchemy. You saved millions of hours of developer time and god knows how many SQL bugs have been prevented by using SQLAlchemy
- kstrauser 4y agoI agree completely. Turns out all those TypeErrors that suddenly popped up when switching to Python 3 were actually uncaught logic errors all along. The biggest annoyance coming from the string/bytes split was realizing how sloppy I'd been about treating them identically.