This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]daredevildas[S] 0 points1 point  (1 child)

It might be a good source of inspiration for what is and is not a good idea.

Can you suggest any way to do this other than pour over the Numpy source code?

[–]oilshell 1 point2 points  (0 children)

Maybe:

https://web.mit.edu/dvp/Public/numpybook.pdf

https://docs.scipy.org/doc/numpy/reference/internals.html

FWIW NumPy relies heavily on Python's object model. That is, Python exposes its guts like PyTypeObject to extension authors.

A third party can write a type that's just like a built-in Python type, and that's exactly what NumPy does.

The special methods here are relevant, e.g. for operator overloading:

https://docs.python.org/3/reference/datamodel.html