r/godot • • 2d ago

help Fast Array Library?

Does anyone know of an extension that provides Numpy-esque arrays? with slicing and fast math operations. I feel like this is a commonly desired feature so I would be surprised if it didn't exist. If not, I may look into making one myself.

16 Upvotes

6 comments sorted by

9

u/lurking_physicist 2d ago

I tested numdot for a backburner project a while ago. It worked out of the box but I didn't push it to see performances.

2

u/oSettergren 2d ago

This seems to be exactly what I want, thanks!

4

u/Phygames 2d ago

I haven't tried myself in context of Godot, but if you use C# you should have different vector/array math libraries available.

Compute shader could be another choice if you just want to accelerate math operations over arrays.

5

u/Past_Permission_6123 2d ago

Depending on what you're doing, it might be possible to use DrawableTexture2D with 32-bit float components. At least math operations will be much faster with custom shaders, as they run on the GPU.

2

u/Lucasharta 2d ago

i'd definitely check out Godot's packed arrays first, since they're much more memory-efficient than regular arrays and can be faster for numeric data. they won't give you the full numpy experience though, especially for slicing and vectorized operations, if you need actual numpy-style operations, a GDExtension could make sense, especially if the heavy work is happening on large datasets where GDScript becomes the bottleneck

1

u/worthwhilewrongdoing 1d ago

If you need things that are fast and at scale, you'll almost certainly need to dip into C#. This is outside of my wheelhouse, but from what I understand the go-to library for all this is NumSharp. I'd start my search there.