28 points

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.

permalink
report
reply
6 points

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

permalink
report
parent
reply
5 points

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.

permalink
report
parent
reply
18 points

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.

permalink
report
reply
9 points

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.

permalink
report
parent
reply
3 points

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.

permalink
report
parent
reply
6 points

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

permalink
report
parent
reply
6 points
*

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

permalink
report
parent
reply
3 points
*

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.

permalink
report
parent
reply
5 points

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.

permalink
report
parent
reply

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.

permalink
report
reply
10 points

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

permalink
report
parent
reply

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

permalink
report
parent
reply
2 points

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

permalink
report
parent
reply
3 points

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.

permalink
report
parent
reply
Deleted by creator
permalink
report
parent
reply
12 points

Won’t or can’t?

permalink
report
reply
9 points

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.

permalink
report
parent
reply
4 points

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

permalink
report
parent
reply
2 points

Oof.

permalink
report
parent
reply
1 point

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.

permalink
report
parent
reply
8 points

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

permalink
report
reply

Python

!python@programming.dev

Create post

Welcome to the Python community on the programming.dev Lemmy instance!

📅 Events
Past

November 2023

October 2023

July 2023

August 2023

September 2023

🐍 Python project:
💓 Python Community:
✨ Python Ecosystem:
🌌 Fediverse
Communities
Projects
  • Pythörhead: a Python library for interacting with Lemmy
  • Plemmy: a Python package for accessing the Lemmy API
  • pylemmy pylemmy enables simple access to Lemmy’s API with Python
  • mastodon.py, a Python wrapper for the Mastodon API
Feeds

Community stats

  • 733

    Monthly active users

  • 469

    Posts

  • 2.4K

    Comments