Live data from Hacker News

NumPy 2.0

numpy.org

51–60 of 78 posts

Re: NumPy 2.0

#51

I'm starting to see some packages break due to not pinning 1.x in their dependencies. `pip install numpy==1.*` is a quick and hacky way to work around those issues until the ecosystem catches up.

"numpy~=1.0”

Is this not common knowledge? Also, pip install? Or do you mean some requirements file?

Re: NumPy 2.0

#52
post #42
post #16

The thing I want most is a more sane and more memorable way to compose non-element-wise operations. There are so many different ways to build views and multiply arrays that I can’t remember them and never know which to use, and have to relearn them every time I use numpy… broadcasting, padding, repeating, slicing, stacking, transposing, outers, inners, dots of all sorts, and half the stack overflow answers lead to th…

It gets more comfortable over time, but I remember feeling that way for the first year or three. My wishlist now is for most of numpy to just be a really great einsum implementation, along with a few analogous operations for the rest of the map-reduces numpy accelerates. I've been writing my own low-level numeric routines lately, so I'm not up-to-date on the latest news, but there have been a few ideas floating aroun…

I want to second the idea of broadcasting based on named axes/dimensions. I think it's a logical next step in the evolution of the array programming paradigm.

I particularly recommend checking out xarray. It has made my numpy-ish code like 90% shorter and it makes it trivial to juggle six+ dimensional arrays. If your data is on a grid (not shaped like a table/dataframe), I see no downsides to using xarray instead of bare numpy.

Re: NumPy 2.0

#53

it feels like the first major release in 18 years which introduces lots of breaking changes should just be a fork rather than a version. let me do `pip install numpy2` and not have to worry about whether or not some other library in my project requires numpy<2.

From a consumer (developer consumer) point of view, I hear you. From a project point of view, there are some pretty strong contra-indicators in the last 20 years of language development that make this plan suspect, or at least pretty scary — both Perl and Python had extremely rocky transitions around major versions; Perl’s ultimately failing and Python’s ultimately taking like 10 years. At least. I think the last tim…

i think it’s fair to say that perl6 has been an “extremely rocky transition” ultimately it was renamed raku to reflect this and avoid camping on the perl5 version numbering

raku has good package compatibility via Inline::Perl5 and Inline::Python and FFI to languages like Rust and Zig

among the many downsides of the transition, one upside is that raku is a clean sheet of paper and has some interesting new work for example in LLM support

I have started work on a new raku module called Dan::Polars and would welcome contributions from Numpy/Pandas folks with a vision of how to improve the APIs and abstractions … it’s a good place to make a real contribution, help make something new and better and get to grips with some raku and some rust.

just connect via https://github.com/librasteve/raku-Dan-Polars if you are interested and would like to know more

Re: NumPy 2.0

#55
post #7

Earlier quoted context omitted.

No. Native python ops in string suck in performance. String support is absolutely interesting and will enable abstractions for many NLP and LLM use cases without writing native C extensions.

> Native python ops in string suck in performance. That’s not true? Python string implementation is very optimized, probably have similar performance to C.

For numpy applications you have to always box a value to get a new python string. It quite far from fast.

Re: NumPy 2.0

#56
post #16

The thing I want most is a more sane and more memorable way to compose non-element-wise operations. There are so many different ways to build views and multiply arrays that I can’t remember them and never know which to use, and have to relearn them every time I use numpy… broadcasting, padding, repeating, slicing, stacking, transposing, outers, inners, dots of all sorts, and half the stack overflow answers lead to th…

What do you mean by: "more memorable way to ..." ?

Re: NumPy 2.0

#57
So apparently this is what broke my CI job since it was indirectly installed. One of the downsides of using loose version locking with requirements.txt rather than something like poetry I guess.

Re: NumPy 2.0

#58

Earlier quoted context omitted.

To be honest einsum is the easiest one. You get fine control on which axis matmul to which. But I wish it can do more than matmul. The others are just messy shit. Like you got np.abs but no arr.abs, np.unique but no arr.unique. But now you have arr.mean. Sometimes you got argument name index, sometimes indices, sometimes accept (list, tuple), sometime only tuple.

https://github.com/mcabbott/Tullio.jl is my favorite idea for extending einsum notation to more stuff. Really hope numpy/torch get something comparable!

Yeah, Tullio.jl is a great package. Basically, it is just a macro for generating efficient for loops.

I guess, it might be hard to achieve similar feature in Python without metaprogramming.

Re: NumPy 2.0

#59
post #16

The thing I want most is a more sane and more memorable way to compose non-element-wise operations. There are so many different ways to build views and multiply arrays that I can’t remember them and never know which to use, and have to relearn them every time I use numpy… broadcasting, padding, repeating, slicing, stacking, transposing, outers, inners, dots of all sorts, and half the stack overflow answers lead to th…

Most of the bugs I got on numpy programs came from a variable with a different ndims as expected being broadcast implicitly.

Implicit type casting is considered a mistake in most programming languages; if I were to redesign numpy from scratch I would make all broadcasting explicit.

My solution to these problems is asserting an array's shape often. Does anybody know is there's a tool like mypy or valgrind, but that checks mismatched array shapes rather than types or memory leaks?

Re: NumPy 2.0

#60

Earlier quoted context omitted.

The most important changes are deprecations of certain public APIs: https://numpy.org/devdocs/release/2.0.0-notes.html#deprecati... One new interesting feature, though, is the support for string routines: https://numpy.org/devdocs/reference/routines.strings.html#mo...

This one will be rough :| > arange’s start argument is positional-only

Looks like that might get reverted [0].

[0] https://github.com/numpy/numpy/pull/25955

Post reply on HN