Hacker Read top | best | new | newcomments | leaders | about | bookmarklet login

numpy doesn’t get sent to the client if you use it on the server.

> JavaScript frontends are becoming unnecessarily bloated



sort by: page size:

Ah ok, by "numpy wouldn't work in JS" you meant something like it wouldn't be popular or as loved. Makes more sense now.

To do that you first need to have a way of extending JavaScript with C and/or Fortran. No way numpy can be implemented in pure js or python without being excruciatingly slow.

This was posted multiple times on HN over the past 5 years.

And every time I see it, I cry that JavaScript doesn't have something like numpy.

numpy is just so damn logical and fast (and comprehensive!) that i don't consider myself a python programmer, i'm a numpy user.

EDIT: (removed complaint). That said: this looks like a good foundation for someone to use for implementing a fully featured numpy in JS.


They must be doing something else with numpy as Python has a generic API, that allows direct access to data of numpy array-like structures: Buffer Protocol https://docs.python.org/3/c-api/buffer.html

But numpy is using LAPACK as its backend…

Numpy has a very poor API compared to Julia, Matlab, Mathematica, R. That’s just me comparing to the ones I know. It’s a mishmash of methods and functions, in-place operations and non-modifying operations, confusing indexing and broadcasting API. There are much better things available for array manipulation.

Not everything is amenable to numpy and it's pretty easy to make performance worse by throwing numpy at every problem. For example, if your array contains Python objects that are part of an operation, you've likely just introduced a significant performance regression. Worse, there's no way to detect these regressions except to have performance tests. Please, don't understate GIL issues.

- everyone using numpy

numpy allows you to do some pretty low level stuff (like creating buffer from a raw pointer), which GAE wants to avoid for obvious security issues. Same rationale as why ctypes (parts of the stdlib) is not available.

I have never used numpy on GAE, but I would suspect some of it is not enabled for those reasons.


>Either implement numpy equivalent on your own or half of your code is data massaging data between libraries

I haven't tested this but here you go:

https://github.com/numcl/numcl


> NumPy is a crappily designed library

I don't think you know what you're talking about.


< numba and numpy do not interact well at all

Can you please elaborate on this? Not challenging you but trying to understand the nuances.

Numba tutorial says otherwise: https://numba.pydata.org/numba-doc/dev/user/5minguide.html "Numba likes NumPy functions"


In particular, does this mean Javascript has access to Numpy? Sounds unbelievable, but would be extremely cool.

As an occasional numpy contributor, I would call this a bug.

Doesn't work because there's no numpy installed in the node image:

>ModuleNotFoundError: No module named 'numpy'


Out of curiosity, what are you doing for which arrays are more suited than NumPy?

I've been using NumPy for a while now, and I've literally never had a reason to use array.array where NumPy arrays have worked.


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

So rather than spend 10-20 minutes reading about numpy, the author wrote 3 other implementations...?

The fact that they ran the C code without the optimisation flags and compared it that way makes me think Javascript was what they actually wanted to write this one in anyway.


Thank you! So this looks interesting but it seems like there's no easy way to share numpy arrays?

The main use case for a language other than python is a more robust codebase but also performance. We need to be able to efficiently ship lots of large arrays between the languages and the Rust-Python interop supports zero copy arrays for example.

next

Legal | privacy