← Back to context

Comment by ayhanfuat

15 hours ago

It is not that numpy bypasses public interfaces. It uses documented C APIs. V8, as far as I know, does not have that.

V8 itself might not, but, say, Node does and that doesn't torpedo performance. Was Node-API just better designed than Python's FFI?

  • My understanding is that Node still doesn’t give you low-level C APIs into the language itself. It gives you JavaScript APIs that call into I/O libraries (libuv basically).

    Python it’s not hard to write a module in pure C that manipulates other Python objects. This means the representation of Python objects has to be stable enough for the C code. V8 does not allow that.

    • I haven’t tried it myself but I don’t think that’s the case. See the documentation here:

      https://nodejs.org/api/n-api.html

      I’ve only skimmed this, but it sure sounds like it lets you write C code that operates on JS objects. In fact, it explicitly says “APIs exposed by Node-API are generally used to create and manipulate JavaScript values.”