Console? good, GUI? good, game dev? use Godot engine with its similar language Gdscript, but what else? Ive been seeing AI, Data Science stuff, but whats the point if ita slow?
In my experience, GUI was horrible because of the GIL. Python is nice because you can write and read it quickly, and packages like numpy allow you to use very natural syntax. Most of the numerical packages wrap C/C++/Fortran binaries which are very optimized. You just have to keep in mind not to do that kind of stuff directly in Python, write tight loops, etc.
Because it is easier to read large codebases of Python than large codebases of Bash.
People who say “Python is slow” are generally wrong, yes, the language is slower then C in basically everything and it also almost always doesn’t matter.
The bottleneck in a console app is not your applications ability to process, it’s your ability to read and type, you will have the same experience in any language.
The same is true with GUI apps, python GUI apps are generally just bindings to toolkits written in other languages like pyqt is a python wrapper around a C++ toolkit.
In actual gamedev, something like Pygame is using SDL which is a C library.
YouTube is a python web app.
Yes, python is slow, and generally it doesn’t matter, if it’s slow then it’s usually a PEBCAK problem. Python is primarily used as an easy to write language that is gluing together more complicated things written in faster languages.
Like bash, but readable by humans!
The reason anyone thinks it’s slow is that in the real world, people still ship* Python scripts/projects that don’t offload their performance-sensitive code to faster solutions.
Acting as glue isn’t unknown to anyone looking into Python either, problem being there are multiple different solutions that each have their own benefits/drawbacks that will differ based on the use-case. Fine if you can lean on an existing library, more complicated if you actually need to write the performance-sensitive code.
Similar to @Chais@sh.itjust.works, plus newer compile-to-C/C++/JS languages offer a lot of what Python does (glue, whitespace, style) plus more stuff like UFCS.
My preference is nim-lang, it has stuff like
for i in 1..17:(or something like
for h in 0.uint8..<height:. Typing is a thing but doesn’t stop me, so either not a big hurdle or there’s something with my brain that makes it fine despite issues with other languages/styles). Nimscript is an option, and I like Clang withopt:sizefor an efficient testing option (Bellard’s TCC was an even better option for quick iteration in the past, not exactly supported now (as of 2023) though. Might work for other languages).* my last experience with this was a piano thing (soundfonts for MIDI keyboard) that had choppy audio when played too quickly and would crash my Raspberry Pi 2B. The issue was closed as
not planned.
Assuming this is a genuine question and not just trolling.
Python’s main feature, IMO, is that it’s easy to pick up. You don’t need to remember to put a semicolon after nearly every line, so you don’t need to remember which lines don’t need it. Basically you only need to remember to put a colon before an indented block.
Thanks to significant whitespace even bad code will be moderately legible.
Control flow and loops are basically written in plain English:for i in range(17):as opposed to e.g.for (int i=0; i<17; i++) {.
This all reduces the mental load and thus leaves you with more capacity to focus on the task you’re trying to solve.
It’s a great language to give to your mathematicians, data scientists and other people with rudimentary programming knowledge at best.As for the performance: interpreted languages are inherently slower than compiled ones. You don’t get a speed boost from first asking a separate program to translate the next line of code into a machine readable format before executing it. Just like you don’t get a speed boost from executing all your cod in a virtual machine. Looking at you, Java.
But you don’t use python for the compute-heavy tasks. You use it for the plumbing in between and outsource the computation to a native library with python bindings, like NumPy, Pandas, PyTorch, etc. Horses for courses.By the time you finish your C script, compile it and run, Python developer will already have finished. Speed is relative.
The python developer already tested, failed and fixed a thousand times by the time the C++ developer is compiling it’s first version
Tested, failed, and fixed a thousand type errors!
pish posh
What’s the point of anything? I have all these Electron apps on my devices which require Gigabytes of memory, Discord took a substantial amount of RAM my old laptop had. There’s Android apps which are hundreds and hundreds of megabytes and all they do is call some REST APIs. Lemmy’s protocol is terribly inefficient. And back in the day in the 90s an entire office suite fit on a bunch of floppy disks. And a 0.025 GHz CPU was all it took to run it… The internet was so much more efficient, you do your online banking, chat, read the news (without a lot of images) with 0.1% of today’s internet connections.
Python is a good first language to learn programming because the syntax is easy (eg. no semi-colons at the end of each line).
In particular you’ll be able to switch to Julia with ease.
It’s fast enough. People talking about modern CPUs have missed the point that python has been a staple language for gui and web apps for like 20 years.
Things I do in Python don’t require speed
define slow.
my life has been in C style languages but even i kniw python us a great general purpose language. are you going to use it for high frequency trading? no but most things dont need that speed.
yes its used a lot in ai but also for a ton of linuc scripting. i dont think anyone uses perl anymore.
so in what way was it slow when you used it? what micro seconds were you lookong for?
Python is slow enough to notice in fairly normal usage. Just doing lookups into a dict with thousands of entries, for example, will lead you to researching how to sort and index it.
Python’s great as an interface to C which gives it the illusion of performing well.
Yeah, want to take a bet on how long a single lookup in a dict with 5,000 entries takes on my machine?
How to sort and index it
It’s a hash table. Can you explain why “sorting and indexing” would improve performance?
You’re talking out your arse.
You’re talking out your arse.
And honestly - what do you expect for a response with a shitty attack like that? Do you need to be a dick?
I mis-remembered, it was a linear search though a list rather than a dict that was the problem (I think it was a list because we were looking up multiple entries or something from a list of Objects based on a field). O(N) lookup to be sure so not well optimized. But on list of 100,000 items doing 100,000 lookups it is very slow - > 1 minute whereas in Java it was like a few seconds.
Yes - refactoring was the solution. I’m not saying it couldn’t perform better and it did when we re-wrote it. But that’s a low-enough number of items that it surprised me that it was a problem.
An order of magnitude difference between python and java would not surprise me at all, sure.
I wrote a console tictactoe game with primitive AI opponent using both Python and C++ and python takes more time in the background process before making a move than in C++.
Yeah, computationally intensive stuff is going to be slow when implemented in Python. You will find lots of data science libraries for Python that do computationally intensive stuff, but they’re then generally implemented in C/C++ or Rust, with only a thin API layer written in Python.
I started off with programming languages that compiled into binaries. I knew dos and bash well enough but wanted the convenience of scripting, just type in run, no compiling needed. I also wanted it to be cross-platform.
I chose Perl. TBH I loved it, but I kept hearing about all the cool things that would come as soon as Perl 6 was released, so I started waiting, and waiting, and waiting…
The XKCD comic, import antigravity, is literally what convinced me to try python finally. Haven’t really looked back, even 13 years later when Perl 6 was finally released
This probably depends on what CPU someone has, someone with a higher-end CPU (higher-IPC/higher clockspeed) probably will have a better experience.
On older/lower-end CPUs it is more common to see when something is single-threaded especially when it’s also interpreted. Particularly any type of generator/loader, filter, renderer, live audio. Which to be clear, is from a user perspective.
I think with newer CPUs Python’s current speed will be less of a problem but if your intention is game dev I think this is not enough.
Yeah you shouldn’t be game deving with a scripting language. There’s your problems!
When used for much of the fancier stuff, like AI, it’s not running in python. Python is just setting up all the other stuff and making the calls to shove the models onto the GPU and configure and blah blah… You’re just writing the program that uses the ML libraries that make other types of programming do the real work, like CUDA or the other one I forgot the name of, or even Vulkan, or what have you.
So while Python is slow, things written in it do not have to be slow.
Similar to Godot’s language. It’s terribly inefficient, but it’s meant mostly to respond to human time scale events, not to have complex computation-heavy systems written up in it. And similar to Python with AI tools and whatnot, Godot’s graphics side is still running hot and fast in the GPU with dx/vulcan even while the language the UI and game logic is written in is inefficient.
“Similar to Godot’s language. It’s terribly inefficient”
Don’t know what you mean, but Godot app is only around 3mb, and it’s not as bloated as Python, though it has some high level layers or somthing too, and not as direct as C++.
They mean scripting, GDscript is also interpreted (and probably also not often parallelized) so it’s also not blazing fast (though I guess typing helps).
Though Godot has many options for languages (including bindings), so compiled is an option (you don’t have to go all in on one language either, so something like a generator or multiplayer code etc needing more performance can use a more capable language).
I bought my house migrating days long Excel processes into minutes python script. They could be seconds C++ programs? For sure. But they would be unmaintainable and would take way too much time to write.
People often forget compute is cheaper than dev hours and unless you’re operating at hyper scale, optimization is often not needed. Most are writing internal programs used by a few thousand people at most
Depending on the project, development speed is often critical. Lots of data science stuff is really ad hoc and doesn’t get reused much, just some math, biology etc. graduates doing number crunching on specific datasets. Sure the script might take a day to execute, but if it’s only actually getting used a single or double digit number of times, it doesn’t make sense to break out more low level languages.
With commercial projects, it’s often an issue of whether the higher hardware requirements of a project done in a scripting language are offset by the longer development time and higher wages for sufficiently competent programmers to do it in more low-level languages. This does have environment implications, but commercial projects don’t typically give a damn about socialized costs (despite the lip service that many had adopted for a while).
AI seems mental, though, unless Python is just some glue for calling functions or libraries that are implemented in lower-level languages, which is definitely also a thing.
AI seems mental, though, unless Python is just some glue for calling functions or libraries that are implemented in lower-level languages, which is definitely also a thing.
Most of the work is done by parallel compute hardware on most systems, not the CPU running Python.
As a beginner, these AI frameworks are written and C++ and you can do it there, but nobody does it and all the books out there or video courses are specifically for Python.
Easy to whip something quick up.






