34
Is Python Really That Slow? (blog.miguelgrinberg.com)
top 24 comments
sorted by: hot top controversial new old
[-] SatyrSack@feddit.org 47 points 1 month ago

Python is by far the fastest to write, cleanest, more maintainable programming language I know

Maintainable? I have not ever had to work with any large Python projects, but from what I have heard, maintenance is a large pain point.

[-] aluminium@lemmy.world 12 points 1 month ago

Also fastest to write? I'd say JS or Ruby are just as fast or barley slower.

What most people mean is that Python has great Libraries which do the thing you want without much fuss. But thats more on the libraries than on the language.

[-] SatyrSack@feddit.org 9 points 1 month ago

I do not know Ruby, but Python has a lot of syntactic sugar that, if one becomes used to and proficient with it, makes writing much faster than other languages I know (including JavaScript).

[-] GissaMittJobb@lemmy.ml 8 points 1 month ago

Ruby has enough syntactic sugar to give you type 2 diabetes honestly.

[-] pupbiru@aussie.zone 5 points 1 month ago

i’m proficient in all 3, and i can say with great certainty that generally python is far faster to write

certainly when you’re talking about JS rather than TS, and achiving a usable outcome rather than bashing together bug-ridden trash

[-] 8hob@programming.dev 10 points 1 month ago

There's one key qualifier in this sentence: I know. One's skill set matters, I guess...

[-] xigoi@lemmy.sdf.org 2 points 1 month ago

Let me guess: The author knows Python, C, C++, Java and maybe PHP.

[-] FizzyOrange@programming.dev 8 points 1 month ago

It's not too bad if you strictly enforce Pyright, Pylint and Black.

But I have yet to work with Python code other than my own that does that. So in practice you are right.

[-] eager_eagle@lemmy.world 4 points 1 month ago

There are dozens of us. Dozens!

[-] lime@feddit.nu 6 points 1 month ago

i had the misfortune once of having to try to understand a >400kLoC python codebase in a critical position and let me tell you that maintainability is a Problem. the system was older than most of the best practices of today and had a structure i can only describe as "a duolith of sqlalchemy soup".

[-] jjjalljs@ttrpg.network 5 points 1 month ago

My work uses python and it hasn't been bad for new code that has tests and types. Old code we inherited from contractors and "yolo startup" types is less good, but we've generally be improving that as we touch it.

[-] Reptorian@programming.dev 2 points 1 month ago* (last edited 1 month ago)

My small Python (~100 lines of codes) codes aren't maintainable, but I'm happy with them. I don't ever plan to work on serious projects with Python, so I can't say much about it's maintainability. But, from limited experience, I'd rather use C++, C#, or in my special case, G'MIC if maintainability matters to me.

[-] onlinepersona@programming.dev 1 points 1 month ago

Python has typing hints which mypy uses. It's similar to something javascripts wants to introduce call type annotations. It also has linters and formatters (ruff which does the work of multiple tools in one and is very fast). It also has unit tests built in as well as popular test libraries like pytest and nox and tox for running tests.

It is up to the maintainers to use the tools they have been given to make projects maintainable. I have worked on and seen very maintainable python projects of various sizes. While legacy code is always a bit of a nightmare (python 2 and < python 3.6), it doesn't have to be that way and getting into a python project nowadays is way easier than most other languages I've tried (maybe also because it's what I know well).

Anti Commercial-AI license

[-] Hugin@lemmy.world 1 points 1 month ago

Yup. Part of what makes python so easy and fast is the lack of things built into languages so they are maintainable in a large project.

Take duck typing. It's so easy when you have a small project that can fully understood by a developer. Get into a big project with 10000 classes and you need explicit classes and interfaces just to understand what is going on.

[-] FooBarrington@lemmy.world -1 points 1 month ago* (last edited 1 month ago)

Python is by far one of the worst languages I've ever seen in relation to maintainability, second only to Javascript (due to missing types, which are fixed by Typescript).

Seriously, it's rare for a Python project with more than 1,000 lines to not turn into an absolute mess thanks to the layers upon layers of meta programming, weird edge cases and so on. There are whole bad patterns I've never seen beyond Python codebases.

Things are improving slowly thanks to type hints and so on, but they are still far from where they need to be. Python is used in even more dynamic ways than JS, so the type system needs to be more expressive than TS. You can't even define a function that appends two tuples with proper type hints!

[-] onlinepersona@programming.dev 1 points 1 month ago

I don't know when the last time you worked on a python project was (professionally or privately), but things have changed. If all you know if python and python projects from 10 years ago, I'd agree with you, but modern python projects can be made very maintainable. See my other comment.

As for meta programming, dude, I don't know if you're seen C++ templates...

Anti Commercial-AI license

[-] FooBarrington@lemmy.world 2 points 1 month ago* (last edited 1 month ago)

Yes, they can be written in maintainable ways, I didn't disagree in my original comment. That doesn't change that most of the projects I come across to this day are absolutely unmaintainable messes. I'm not talking about Python from 10 years ago, I'm talking about the projects I encounter now.

The biggest issue is that you have to limit yourself to a mostly non-dynamic subset of Python if you want type checking etc. to work, and you have to write your own type definitions for many dependencies. Most projects don't do that, they instead lean into the dynamic nature of Python, which makes them unmaintainable after little time.

[-] superfes@lemmy.world 20 points 1 month ago
[-] SatyrSack@feddit.org 14 points 1 month ago

It seems "vanilla" Python is slow, but a JIT implementation like PyPy can speed things up significantly. The major downside seems to be that PyPy does not support Python code that relies on some CPython libraries.

[-] sugar_in_your_tea@sh.itjust.works 6 points 1 month ago

But it's fast enough for us.

[-] andrew_s@piefed.social 10 points 1 month ago

Oh man, it's only from reading this that I've realised that 'pypy' isn't the same as 'pypi'

Python is a great language for folks who occasionally have to do a little bit of programming, but if you have to go into any depth with it you hit shit like that.

[-] 30p87@feddit.org 6 points 1 month ago

For normal stuff, yes. For things that are implemented in C and just interfaced with in Python, so the majority of data analyis and ML libraries, no.

[-] Reptorian@programming.dev 2 points 1 month ago* (last edited 1 month ago)

In my experience, it is.

I had converted a Python code into G'MIC, and then some one else did a Python version of my own code. G'MIC is interpretative with JIT math parser. The results:

Reversing digits in a 1024x1024 RGB image.

Python: Without lookup table and numpy - 3+ minutes

Python: With lookup table and numpy - 6.5 s (Some one else machine, but it shouldn't take that long)

G'MIC: Without lookup table - .3 s

G'MIC: With lookup table - .005 s

And I did Lavander Binary Map on my machine, you can find code for Python version in github/gmic-community/include/reptorian.gmic:

Python: 3 s (Without lookup table)

G'MIC:.15 s (Without lookup table)

G'MIC: .05 s (With lookup table)

Honestly, I find Python pretty bad for image processing in general.

this post was submitted on 18 Nov 2024
34 points (87.0% liked)

Python

6474 readers
1 users here now

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

📅 Events

PastNovember 2023

October 2023

July 2023

August 2023

September 2023

🐍 Python project:
💓 Python Community:
✨ Python Ecosystem:
🌌 Fediverse
Communities
Projects
Feeds

founded 2 years ago
MODERATORS