Python developers won’t let go of Python 2 (www.infoworld.com)
from ruffsl@programming.dev to python@programming.dev on 06 Oct 2023 00:11
https://programming.dev/post/3988653

#python

threaded - newest

GammaGames@beehaw.org on 06 Oct 2023 00:33 next collapse

I had no idea, never having to deal with library updates must be nice 😆

beautiful_boater@hexbear.net on 06 Oct 2023 00:42 next collapse

Well, TBF there is a lot of avenues to get locked into legacy software in python. I am still modifying and using Python2 code because the drivers and libraries for hardware are only available in python2 and the hardware developers wont spend the money and time to create Python3 libraries. So I am stuck using an airbridged, un-updated python2 environment until it gets to the point of updating/backwards engineering python3 drivers and libraries for all our hardware ourselves.

naonintendois@programming.dev on 06 Oct 2023 00:53 collapse

What hardware drivers are written in Python? I would assume they’re bindings to drivers with a C interface.

[deleted] on 06 Oct 2023 00:58 next collapse
.
beautiful_boater@hexbear.net on 06 Oct 2023 01:00 next collapse

I should have been more specific. Yes, it is a wrapper around a closed source blob.

hosaka@programming.dev on 06 Oct 2023 02:41 collapse

Take a look at micropython, some drivers are writing in pure python, I’ve written a display driver previously

naonintendois@programming.dev on 06 Oct 2023 04:45 collapse

I assumed those were for hobbyists. I would be surprised if that was used in a major product given how many cycles you lose to python implementation.

hosaka@programming.dev on 06 Oct 2023 17:12 collapse

Yeah you’re totally right. Nonetheless the use case has it’s place. People buy and use hobbyist hardware, and this is a market on its own.

rockSlayer@lemmy.world on 06 Oct 2023 00:48 next collapse

At this point Python 2.7 should be forked into a new language. They could call it something like Daudin, after the person who coined the word Python for the genus of nonvenomous snakes

NegativeLookBehind@kbin.social on 06 Oct 2023 03:03 next collapse

Snek2.7

rockSlayer@lemmy.world on 06 Oct 2023 05:44 next collapse

Yea, fuck my name this is way better

finickydesert@lemmy.ml on 06 Oct 2023 11:36 collapse

Danger noodle 2.7

falsem@kbin.social on 06 Oct 2023 06:45 next collapse

You'd have to find someone interested in maintaining it for at least security fixes and I'm guessing everyone capable is more interested in just working on new stuff for Python 3.

jelloeater85@lemmy.world on 06 Oct 2023 20:31 collapse

Someone submit a PEP for it!

JigglySackles@lemmy.world on 06 Oct 2023 01:20 next collapse

I don’t do enough for it to matter, what’s wrong with 3?

agressivelyPassive@feddit.de on 06 Oct 2023 01:38 next collapse

It’s different enough.

There are huge python 2 codebases that can’t easily be ported to python 3.

Vamanos@lemmy.world on 06 Oct 2023 01:49 collapse

Meh. I’ve ported a fair many py2 projects to 3. At this point just bite the bullet. Even from a security standpoint. Trying to not let my bias seep through - but it’s been so long.

agressivelyPassive@feddit.de on 06 Oct 2023 03:00 collapse

Ever worked on a giant corporate codebase? I’m not saying you’re wrong, but corporate internals often work counter to common sense or sanity. You’ll have a giant mess of code, that would require months of work to port. The longer you wait, the more expensive it will get, but if you just wait long enough, it might not be the current manager’s problem anymore. So it will be postponed and postponed.

I’ve seen this in real life a few times. EOL driven development. You just wait until it’s absolutely impossible not to upgrade, then you hastily stop everything, do the porting in a marathon of sadness that basically rewrites everything, and if you’re done, you can wait for the next EOL.

luckystarr@feddit.de on 06 Oct 2023 03:51 next collapse

The trick is to assign someone the responsibility of the upgrade and give them the authority to tell the other developers how their newly added code shall look like. This will get you there eventually.

Seen it work on a >1 million SLOC project.

bane_killgrind@kbin.social on 06 Oct 2023 04:02 next collapse

Yeah but that requires good planning and better team structure.

That's low margin and therefore doesn't happen often enough.

agressivelyPassive@feddit.de on 06 Oct 2023 05:13 collapse

This will get you there eventually.

Only if you can actually upgrade piece by piece. In a monolith, you often enough can’t just upgrade new lines/methods. In those cases, it’s halt all development, pull everyone into upgrading and then continue.

Vamanos@lemmy.world on 06 Oct 2023 04:21 collapse

20 years on giant enterprise codebases. And any enterprise worth their salt at this point will be scanning these servers and flagging eosl software.

My experience the last five years of the 20 - security and service life trumps all fucking complaints about complexity.

To the point where it’s the opposite and I’m fielding weekly questions about why we’re still running an older 3.7.9 version. Among 50 other things.

agressivelyPassive@feddit.de on 06 Oct 2023 05:10 collapse

Yet, there are enough companies that simply don’t care. Yes, that’s bad, but it’s also reality.

Narann@lemmy.world on 06 Oct 2023 06:12 next collapse

Nothing, because it’s not related to Python 3.

o11c@programming.dev on 06 Oct 2023 20:04 collapse

Python 2 had one mostly-working str class, and a mostly-broken unicode class.

Python 3, for some reason, got rid of the one that mostly worked, leaving no replacement. The closest you can get is to spam surrogateescape everywhere, which is both incorrect and has significant performance cost - and that still leaves several APIs unavailable.

Simply removing str indexing would’ve fixed the common user mistake if that was really desirable. It’s not like unicode indexing is meaningful either, and now large amounts of historical data can no longer be accessed from Python.

JigglySackles@lemmy.world on 07 Oct 2023 00:33 collapse

Thanks for that context. Seems odd that they would remove the str instead of taking the time to fix it.

o11c@programming.dev on 08 Oct 2023 01:41 collapse

It’s because unicode was really broken, and a lot of the obvious breakage was when people mixed the two. So they did fix some of the obvious breakage, but they left a lot of the subtle breakage (in addition to breaking a lot of existing correct code, and introducing a completely nonsensical bytes class).

dingleberry@discuss.tchncs.de on 06 Oct 2023 03:56 next collapse

Won’t or can’t?

icedterminal@lemmy.world on 06 Oct 2023 06:36 next collapse

Both. There are many breaking changes that can make your code completely incompatible. Some people won’t bother to port their code. Others could be using an obscure or niche library that hasn’t been updated for 3 and can’t port their code.

kogasa@programming.dev on 06 Oct 2023 20:34 collapse

Third category, software provided as part of an ancient service contract that nobody is allowed to touch, even though the service partner stopped offering support for this particular software years ago. Ask me how I know

icedterminal@lemmy.world on 06 Oct 2023 20:35 collapse

Oof.

dallen@programming.dev on 07 Oct 2023 08:05 collapse

At the old job I was using IronPython (2.7) to write Grasshopper plug-ins in the Rhino CAD software. Luckily, it was mostly responsible for kicking off Python3 and Go subprocesses.

Now, the worst I’m stuck with is 3.8 for one of our repos using PyTorch.

RedditReject@lemmy.world on 06 Oct 2023 04:18 next collapse

Not sure why it is a big deal for most things. I was a 2.7 die hard and was forced to move to 3.x a few years ago. Had to rewrite a bunch of crap at first but once it was done it’s been a lot better than I thought it was going to be at first.

stevecrox@kbin.social on 06 Oct 2023 07:15 next collapse

Python's public API changes subtly, so minor changes in Python version can lead to massive changes in the version of dependencies you use.

A few years ago we developed a script to update Cassandra on Python 2.7.Y. Production environment used Python 2.7.X (it was 5 patch releases earlier).

This completely changed the cassandra library version. We had to go back 15 patch releases which annoying resulting in a breaking change in the Cassandra libraries API and wouldn't work on the dev environments Python.

Python 3 hasn't solved this, 2 years ago I was asked to look at a number of Machine Learning projects running in docker. Upgrading Python from 3.4 to 3.8 had a huge effect on dependencies and figuring out the right combination was a huge pain.

This is a solved problem in Java, Node.js has the same weakness but their changes to language spec are additive so old code runs on new releases (just not the inverse). Ruby has exactly the same issues as Python

TacoNissan@lemmy.zip on 06 Oct 2023 12:15 next collapse

I swear it’s just as frustrating as Minecraft modding and picking the right forge version for all the mods you want. And OF COURSE your 2 favorite mods aren’t on the same version so you can’t use them together. I’m legit learning to mod Minecraft just so I can port them myself.

Sigmatics@lemmy.ca on 06 Oct 2023 16:55 collapse

I very much doubt that you can run old code unchanged on newer Java versions. Especially not without dependency updates

This problem is not exclusive to Python

brianorca@lemmy.world on 06 Oct 2023 22:06 collapse

Java has had some breaking changes, especially the move to Jakarta namespace for certain dependencies, (thanks Oracle trademark enforcement) but I have had other code taken from 9 to 19 with no changes at all. I have some dependencies that I haven’t recompiled since 6 which still work in 19.

Now dependency dependencies, yeah that can get tricky to get them all the right version.

Narann@lemmy.world on 06 Oct 2023 08:15 collapse

Not sure why it is a big deal for most things.

Close source libraries written by third party contractors in non web/internet/research related domains.

What it means is that you will always have a small portion of Python devs that will stay on Python 2.

Even if you fork it and rename it to Snake 2, you will always have devs working on a language named Python 2.

RedditReject@lemmy.world on 06 Oct 2023 17:32 collapse

I get that. My job is mostly writing Python scripts to keep an old Fortran based framework going, so I cringe when people get married into a language like this. I feel that all code should be adaptable and be able to absorb upgrades and changes. But I certainly understand. From my perspective if they were to rework my old Fortran code, it would take them at least a year or more to do it well. Most companies don’t want to spend that sort of effort.

Overarch3784@kbin.social on 06 Oct 2023 04:23 next collapse

I think the biggest problem would be libraries which are not available in 3.x. I just rewrote a python script some time ago and the syntax changes were pretty easy to change with search and replace.

Dr_Cog@mander.xyz on 06 Oct 2023 22:20 collapse

I don’t see a problem. For one, it’s been 15 years: the vast majority of libraries have been ported by now. And like you said, you can fix the syntax with basically a find/replace script, so any stragglers can be modified easily.

There really isn’t any excuse to still be using Python 2 anymore

Alphare@lemmy.world on 07 Oct 2023 08:31 collapse

While I agree that people should have moved on for a while, the idea that porting Python 2 to 3 only involves “find and replace” or a tool like 2to3 is only true in the most trivial cases. Anything that touches bytes, unicode, network or files to do anything remotely involved needs a lot more care. I should know, our codebase still suffers from the occasional bug due to this, even though it’s been years.

ALERT@sh.itjust.works on 06 Oct 2023 06:17 collapse

yeah. my pain exactly. the only thing that keeps me well is 3.12 in my personal projects.

jelloeater85@lemmy.world on 06 Oct 2023 20:30 collapse

How ya likening the latest hotness?