Live data from Hacker News

Test for lists in Cython

github.com

1–10 of 147 posts

Re: Test for lists in Cython

#4
post #3

From the benchmarks: > Rust is not that fast because it needs to copy data; I'm surprised. Don't know much about Rust, but isn't it hailed as being competitive with C/C++ ?

rust has concept of references, maybe it was referring to its particular implementation of the problem

Re: Test for lists in Cython

#6
I never considered Julia to extend python but it makes sense.

Although as mentioned in the benchmark, with py2o, rust will be a superb contender, especially considering:

- the toolchain is the easiest to setup

- you can embed asm if you really need this extra juice

Re: Test for lists in Cython

#8
I feel like the #1 downside of Python for the last few years is that you cannot take advantage of multiple cores of a CPU easily. Especially when you think it is heavily used in data analysis. We use Python for data analysis as well, and for 95% of operations we are doing, numpy is fast enough that we don't have any complaints. But sometimes, we do wish to be able to take advantage of all the cores in our CPUs, especially now that we can easily get an 8 core CPU for a reasonable price.

There is multiprocessing module but you cannot share memory between processes. I guess the best options are either writing a C extension or using Numba. Writing C extensions require either distributing binary packages or C compiler to be present on the target computer which is not always ideal. So is using Numba the best solution currently? I tried it a bit in the past but the errors I got was a bit hard to interpret compared to regular Python errors.

I wish the multithreading module had support for native threads. Is there any PEPs trying to bring easy multi-core support for Python?

Re: Test for lists in Cython

#9
Rust doesn’t need to copy the data. It’s trivial to pass e.g. Numpy arrays to Rust as slices via Cython (let alone originating in Cython!), modify them, and return them, or use them as input for a new returned struct.

https://github.com/urschrei/simplification

https://github.com/urschrei/lonlat_bng

https://github.com/urschrei/pypolyline

Each of those repos has links to the corresponding Rust “shim” libraries that provide FFIs for dealing with the incoming data, constructing Rust data structures from it, and then transforming it back on the way out.

As a more general comment, using a GC language as the FFI target from a GC language is begging for difficult-if-not-impossible-to-debug crashes down the line.

Re: Test for lists in Cython

#10
post #3

From the benchmarks: > Rust is not that fast because it needs to copy data; I'm surprised. Don't know much about Rust, but isn't it hailed as being competitive with C/C++ ?

The culprit here is `a_list: Vec>`, which means the list of lists is copied as a whole, hence why the rust version is slower.

In general, rust is at least as fast as C or C++, but this seems to be a special case.

Post reply on HN