Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
Liebranca109460dYou could have a preprocessor for the python code. So then you have two versions of a file, one is readable and is used as source, the other is whatever but runs fast(er).
But then it's kind of self-defeating, as in if one is willing to go that extra mile then a compiled language would be more appropriate in the first place.
You could maybe write a patch for python itself then, though that's much more involved. Ugh, never a good option. -
jestdotty561760dI've always disliked python
*takes another spiritual swig of spiritual alcohol and feels superior in own opinions* yep -
Demolishun3505160dI didn't know Python had enums. I checked and it was added 3.4 apparently. I have not done much coding with Python 3. Did a lot of Python 2.
-
Demolishun3505160dYou, know at one time there was a V8 module for Python... I "think" it had JIT...
I will see myself out... -
Hazarth952160dThe secret trick to make your python code faster is to rewrite your code in C++ or another compiled language! Or at least parts of it via linking.
-
atheist998360d@12bitfloat I think you'll find, c++. The arc stuff seems too verbose, tedious and superfluous to me...
Although there is a c++ proposal for safe memory handling. So maybe in 2030… -
atheist998360d@Hazarth "parts of it via linking" yeah... It's just such a pain in the ass to set up. Have you ever tried reading numpy's build system? Fuck that for a laugh.
-
atheist998360d@Hazarth rewriting in c++ however would make it run faster but way slower to develop. I'm just as experienced with c++ as python, but python is batteries included. Rust, a bit better with cargo but... Rust...
-
typosaurus1218060d@atheist I don't know for the JIT but for the real threading you have to compile yourself with the disable gil flag enabled or smth.
Yeah, afaik C++ will get the borrow thing or smth.
It would actually be nice to rewrite your library in C right when it's completed. If it's all thought trough, it should be doable right?
@12bitfloat Rust is a funny dinky toy language only good for writing pygame-like alternatives.
In exception of tsoding, I've never heard someone using c3. c3 is a C alternative. A bit better is the idea. I watched tsoding implementing websockets in it today. C3 didn't had a websocket library yet -
atheist998360d@retoor I'm using pyenv which has a rebuilt threading build so pretty easy. I've also been using a dev 3.14 version for ages because it's got some really nice typing improvements 😁
-
atheist998360d@retoor rewriting in c would be doable but I'm using pandas to parse the utf spec sheets so that supporting new utf versions (that haven't changed rules) is just a case of adding the new spec sheets. But I'm doing it so I can do restructuredtext parsing which would just not be fun to rewrite in c. Maybe c++ but it's all string manipulation which is just a bit easier in python.
-
typosaurus1218060d@atheist tsoding is total fan of zig. That promises something. I didn't try it yet. I have too many projects to learn a language on top of. Since C remains fastest, i keep using that. I was busy learning Rust with minimal effort by watching a 3hr video about it. Watched half, lost interest since I knew i'm not gonna use it. I just wanted to be up-to-date. That's not a good motivation and imo you don't really learn coding from video. At most some concept.
I did learn wren not long ago, very easy js like language and its source code itself is beautiful. I'm a fan, but the language is abandoned. Not the first time this maker abandoned a language. Sad, i wrote networking capabilities for it. The socket server with my lib was as fast as python's async server with heavy load testing using apache benchmark. Still fun project -
Hazarth952159d@atheist have you tried Go? I find It's almost as intuitive to use as Python, but it is a compiled langugage and It's perfect for multi threading
-
Lensflare1747659dJust use Swift. It’s as easy and convenient as python but is compiled and has ARC instead of GC, which is better for performance.
No need to make compromises with C++, Rust or Go. -
lungdart340159dPython isn't for speed critical tasks. And most tasks aren't speed critical.
I've been writing things in python unless I need speed, then relying on c++, and I haven't had to touch c++ in 6 or 7 years. Computers are fast now. -
atheist998359d@lungdart "python isn't for speed critical tasks" if all you've got is a hammer then everything is a nail. I think c++ isn't even about speed, it's about customization. You can probably make python nearly as fast as c++ in 90% of use cases because of numpy etc (not counting them as compiled). Customized c++ is only really necessary when you need so much fine control that you can't use them.
-
lungdart340155d@atheist it's all about delivering value.
If I can write something in an hour in python or a day in c, I'll pick Python.
And the reason you want fine grained control over things when using c/cpp is to optimize for something. Usually speed, but sometimes disk, memory, or bandwidth. -
atheist998355d@AlgoRythm "Easy!" have you tried it recently? The native build process isn't well supported by newer dependency management tools (poetry it's a completely undocumented feature I gave up trying to get to work). For pdm there at least looks to be someone that got it working recently https://rgoswami.me/posts/...
but even then, if I'm writing python is like it to be cross platform so there's the cross compilation hell to deal with too... -
AlgoRythm5025455d@atheist I’ve never used SOs and Python before, I assumed it would at least be well supported
-
AlgoRythm5025455d@atheist python issue 👎 it should be as simple as an import statement, and the VM should search automatically for a .DLL/.LIB file on Windows platforms and a .SO / .A files on *nix systems.
-
atheist998355d@AlgoRythm it "works" nearly flawlessly. But getting it working is like running into a brick wall. We have a work package with python bindings and it's a cmake build system and that's probably the best way to do it. The Python build systems are somewhat lacking for doing something quickly.
Making python 2x faster by replacing enums with literal values.
Pros, it's faster, cons, it's unreadable.
God I miss compiled languages. At least optimizing them requires intelligent problem solving.
It's a text parser state machine transition so it's a code hot spot, so this kind of optimization is worthwhile. But it's kinda annoying.
Next is get rid of any semblance of readability and replace the match with an array index...
rant