Speed up your python by not using python at all. Learn a language that compiles to native binaries and be better off for it. For example: Go, Swift, D.
Nim probably makes more sense if you're coming from Python. Oh, and Python is perfectly fine for most things. If you like it, sticking with it and just speeding up the rare thing that needs that performance makes much more sense than switching language, especially if you already are well into a project.
Speed up your Python using Rust
61–70 of 102 posts
Re: Speed up your Python using Rust
#62> Rust is a language that, because it has no runtime, can be used to integrate with any runtime; you can write a native extension in Rust that is called by a program node.js, or by a python program, or by a program in ruby, lua etc. and, however, you can script a program in Rust using these languages. — “Elias Gabriel Amaral da Silva” Can someone explain why is "having a runtime" problematic for writing extensions an…
"Can someone explain why is "having a runtime" problematic for writing extensions and calling them from Python ?" Perhaps instead of saying "having a runtime" it would be better to examine the situation in terms of what the code assumes. Python assumes that it has the Python GC running on its code, that everything is a PyObject of one sort or another, that it has a Global Interpreter Lock that if taken will prevent a…
I've been left wondering what you meant by this. Are you referring to the stack and heap management? Or OS processes and threads?
If not, could you please explain what you mean by C runtime, and how does Rust differs from it when it is shut down??
Re: Speed up your Python using Rust
#63See also “Fixing Python Performance With Rust” previously discussed here: https://news.ycombinator.com/item?id=12748020 And “Evolving Our Rust With Milksnake”: https://news.ycombinator.com/item?id=15697570 Both from Armin Ronacher at Sentry. About Milksnake: Milksnake helps you compile and ship shared libraries that do not link against libpython either directly or indirectly. This means it generates a very specific t…
Re: Speed up your Python using Rust
#64Earlier quoted context omitted.
If you try to wrap any non-trivial type using SWIG typemaps you will quickly go insane. However to speed up an inner loop you can often get away with a few PyObject* arguments/returns. SWIG will pass those through and you can use the Python/C API directly, e.g. to return a numpy array. Allow SWIG to handle only simple types. The Python/C API is relatively sane, but you'll have to learn the reference counting conventi…
Agreed! On my current project (C++) I found that things get extremely complicated with shared_ptrs and directors. I even ended up contributing some solutions to SWIG. It all appears to be due to a lack of semantics in the C header. SWIG depends on specifying this stuff in the interface file, but I've often wondered if it wouldn't be better to enhance the C-side, either by standard parameter name conventions or by som…
Re: Speed up your Python using Rust
#65Earlier quoted context omitted.
Rust has a big standard library that is linked by default. Using it with no runtime is pretty rough going and is usually done only by people targeting bare metal microcontrollers or OS kernels, because it loses a lot of the power normally available in the language.
What power are you missing? I'm usually surprised by how much still exists without libstd. The biggest thing is collections.
Re: Speed up your Python using Rust
#66See also “Fixing Python Performance With Rust” previously discussed here: https://news.ycombinator.com/item?id=12748020 And “Evolving Our Rust With Milksnake”: https://news.ycombinator.com/item?id=15697570 Both from Armin Ronacher at Sentry. About Milksnake: Milksnake helps you compile and ship shared libraries that do not link against libpython either directly or indirectly. This means it generates a very specific t…
Yeah, Milksnake is mentioned in the article :)
Re: Speed up your Python using Rust
#67Re: Speed up your Python using Rust
#68I've been told not to expect similar results in other implementations. These findings cannot be used to draw any conclusions about pypy.
My rust project: https://github.com/YosaiProject/yosai_libauthz
Re: Speed up your Python using Rust
#69I like the article, but the following advice confused me, especially since this comes from RedHat i.e. Linux people: > Having Rust installed (recommended way is https://www.rustup.rs/ ). This essentially recommends unconditionally using the "curl | sh" anti-pattern. Shouldn't they recommend instead e.g. "apt-get install rustc" for Debian users? Since this doesn't make use of too recent Rust features, using Rust 1.14…
If you look at the way the rustup-init.sh script is written it's safe to be used with this "anti pattern". I see your objection though but unfortunately this ship has sailed, you might as well complain about websites that don't work without Javascript... The advantage of this method is that it will work on any linux distro (and even BSD, Darwin and mingw) and you'll get the latest stable version. I don't see the adva…
The ship hasn't sailed and neither has the sites without JS one. You have made a decision to favor covenience instead of security and you're trying to make it look like it's the normal state of affairs.
Rust can be installed by downloading the appropriate package and checking it with gpg.
Recommending curling stuff to bash is ridiculous and makes a mockery of the idea of safety.
Re: Speed up your Python using Rust
#70Earlier quoted context omitted.
What power are you missing? I'm usually surprised by how much still exists without libstd. The biggest thing is collections.
I have to confess to not actually being a Rust user. But, isn't for example std::io used by most Rust programs?
(It used to use a runtime because it had optional M:N threading, but that was removed when it turned out not to be any faster than 1:1 threading, caused all sorts of problems with stack switching, and of course pulled in a problematic runtime.)