p7g
CPython's slowness doesn't boggle my mind at all. It's a bytecode interpreter for an incredibly dynamic language that states simplicity of implementation as a goal. I would say performance is actually pretty impressive considering all that. What _does_ boggle my mind is the performance of cutting-edge optimizing compilers like LLVM and V8!
At least there is a benefit to a simple implementation: Someone like me can dive into CPython's source and find out how things work.
I ported the Rust documentation as well, using docstrings. The examples in the docstrings are run as tests, and each doctest must be well-typed (according to mypy) for CI to pass.
There are a few reasons why I made this:
- mypy with typing.Optional can enforce checking for None, but it makes me miss Rust APIs like Option.map.
- Python will have pattern matching in 3.10, which will make this library more ergonomically feasible.
- It seemed like a fun and straightforward project.
I'm happy to answer any questions, and would love to hear your constructive criticism.