- cross-posted to:
- python@programming.dev
- cross-posted to:
- python@programming.dev
This was the first time I saw someone refer to Python’s type hints as a performance tool. Up until now, I only saw references to type hints as a way to help static code analyzer tools verify that objects and invocations comply with contracts.
I guess that having additional info at hand to determine how some calls are expected to be made is helpful to gather info to drive optimization steps, but PEP 484 is clear in stating that it’s goal is to help type checkers, and that code generation using type hints might be limited to some contexts.
This sounds like yet another example supporting the old law of interfaces, where all it takes for an interface to be abused is for it to exist.
What I get from this : if performance and speed is not an issue, Python is good. But, if you want speed, use something else (C, C++…).
Python and Rust apparently pair nicely
Could you elaborate on that point? Is it as smooth as using C?
Rust compiles to machine code like C.
Just like you can call binaries written in C from Python and return their result, you can also run binaries written in Rust. In fact, there are helper libraries to provide some syntax to do this.
I assume you meant that both Rust and C compiles into machine code? Python compiles into bytecode that is then run in a VM, Rust and C usually doesn’t do that as far as I know.
I was mostly curious if it was as easy as in C. Turun’s reply answered that question though. Cheers.




