Translating Cython to Mojo, a First Attempt
Posted3 months agoActive3 months ago
fnands.comTechstory
calmmixed
Debate
70/100
MojoCythonScikit-LearnPerformance Optimization
Key topics
Mojo
Cython
Scikit-Learn
Performance Optimization
The author attempts to translate Cython code to Mojo, a new programming language, and discusses its potential applications in scikit-learn, sparking a debate about Mojo's limitations and potential impact.
Snapshot generated from the HN discussion
Discussion Activity
Active discussionFirst comment
4h
Peak period
15
0-12h
Avg / period
5.5
Comment distribution33 data points
Loading chart...
Based on 33 loaded comments
Key moments
- 01Story posted
Oct 6, 2025 at 4:09 PM EDT
3 months ago
Step 01 - 02First comment
Oct 6, 2025 at 7:44 PM EDT
4h after posting
Step 02 - 03Peak activity
15 comments in 0-12h
Hottest window of the conversation
Step 03 - 04Latest activity
Oct 10, 2025 at 11:07 PM EDT
3 months ago
Step 04
Generating AI Summary...
Analyzing up to 500 comments to identify key contributors and discussion patterns
ID: 45495738Type: storyLast synced: 11/20/2025, 6:39:46 PM
Want the full context?
Jump to the original sources
Read the primary article or dive into the live Hacker News thread when you're ready.
Firefox on Android with NoScript.
I just use Quarto to create a static site, but I am also very clueless about web stuff.
From "Building cython extensions using only pyproject.toml (no setup.py)" https://github.com/pypa/setuptools/discussions/4154#discussi... :
Nothing wrong with that as a starting point of course, but it's easier just to compile it as a dependency and look at the core documentation if you're familiar with C++; you'll need to be reading the C++ examples anyway to write Rust code with it.
So if you wanted to write a Python Physics library that included, say, time integration with an implicit solver like those SUNDIALS provides (and SUNDIALS is like the gold standard in this area), you have less well used options for the time integration part if you write the extension in Rust as if you do in C/C++. Or you're using the same library anyway.
> Narwhals: https://narwhals-dev.github.io/narwhals/ :
>> Extremely lightweight compatibility layer between [pandas, Polars, cuDF, Modin]
> Lancedb/lance works with [Pandas, DuckDB, Polars, Pyarrow,]; https://github.com/lancedb/lance
SymPy has Solvers for ODEs and PDEs and other libraries do convex optimization. SymPy also has lambdify to compile from a relatively slow symbolic expression tree to faster 'vectorized' functions
From https://news.ycombinator.com/item?id=40683777 re: warp :
> sympy.utilities.lambdify.lambdify() https://github.com/sympy/sympy/blob/master/sympy/utilities/l... :
>>> """Convert a SymPy expression into a function that allows for fast numeric evaluation""" [with e.g. the CPython math module, mpmath, NumPy, SciPy, CuPy, JAX, TensorFlow, PyTorch (*), SymPy, numexpr, but not yet cmath]
scikits.odes supports CVODE: scikits.odes.sundials.cvode: https://bmcage.github.io/odes/master/api/compat.html#module-....
sckits.odes docs > Choosing a Solver: https://scikits-odes.readthedocs.io/en/latest/solvers.html
scipy.integrate.solve_ivp has Radau, BDF, and LSODA for stiff ODEs, in Python: https://docs.scipy.org/doc/scipy/reference/generated/scipy.i...
If you add Arrow RecordBatch or Table output to CVODE with arrow-cpp, e.g. Dask can zero-copy buffers to Python (pyarrow, pandas.DataFrame(dtype_backend=arrow), or narwhals) when it needs to gather / fan in at a computational barrier in a process-parallel workflow.
Is sklearn-deap useful with scikits.odes and sundials (and dask or not)?
We are heavily leaning on Julia, and to my mind Mojo is a major threat to the long term development of the Julia community. If people dissatisfied with Python+C(++)-Silos end up writing Mojo instead of Julia it will become even harder to grow the ecosystem and community.
That said, for now Julia has a number of big strengths for scientific work that don't seem to be in the focus of the Mojo devs...
I like the language, but as I do ML, Python is really the only game in town, and Mojo is looking promising.
Mojo has 3 disadvantages compared to Julia:
1) The core team is focused on the Linux+servers+AI combination, because that's where the money is.
2) Less composability due to the lack of multiple dispatch.
3) The license.
lolwut
If it's something you need to put in production soon, C++/pybind might be the way to go, but if it's just a side-project, Mojo could work.
Only if you want to lose access to Windows users, as it is a low priority for Mojo development.
We spent decades getting out of the clutches of Mathworks, Microsoft, etc. Why are people eager to go back that way?
The licence is a bit weird to me though. I do get it for their main product, Max, but it is a bit of a weird one for a language.