Skip to content

Support BigInt64Array/BigUint64Array - #43

Merged
mikolalysenko merged 1 commit into
scijs:masterfrom
aschampion:bigint-support
Jan 5, 2020
Merged

mikolalysenko merged 1 commit into
scijs:masterfrom
aschampion:bigint-support

Conversation

@aschampion

Copy link
Copy Markdown
Contributor

Add support for typed arrays of 64-bit integers (BigInt) now available
in many browsers. Without this patch these typed arrays were given the
"generic" dtype, which then attempted to use getters and setters rather
than indexing, causing an error since typed arrays do not provide these.

These changes are compatible with browsers that do not have these 64-bit
typed arrays.

Simple tests are included.

Add support for typed arrays of 64-bit integers (BigInt) now available
in many browsers. Without this patch these typed arrays were given the
"generic" dtype, which then attempted to use getters and setters rather
than indexing, causing an error since typed arrays do not provide these.

These changes are compatible with browsers that do not have these 64-bit
typed arrays.
@aschampion

Copy link
Copy Markdown
Contributor Author

Pinging to see if there's anything I can do to move this towards merging, e.g., more tests. Thanks!

@rreusser

rreusser commented Feb 21, 2019 •

Copy link
Copy Markdown
Member

This PR passes and looks pretty good to me, though I haven't followed the progress of bigint too closely. Does bigint64 make more sense than int64 (and uint64)? Perhaps so since usage is more subtle than int32 vs int64. Other than that, it seems reasonable to me.

Seems similar modules like typedarray-pool and dtype might need similar updates.

Pinging @mikolalysenko for a second opinion.

@aschampion

aschampion commented Feb 21, 2019 •

Copy link
Copy Markdown
Contributor Author

While I personally like the consistency of int64/uint64, for whatever reason the standards committees settled on the BigInt naming scheme for the types and typedarrays, so I think having the strings here consistent with the typedarray prefixes makes the most sense.

My goal is to get this downstream to numjs (since that's the functionality I need for my use). I'm not very familiar with the scijs ecosystem. It looks like I may need to make a PR for typedarray-pool, but I don't see a dependency path through dtype.

e: I now see ndarray-dtype. Not a dependency for numjs, but, yes, seems reasonable to update it and dtype for changes here.

@rreusser

rreusser commented Feb 21, 2019 •

Copy link
Copy Markdown
Member

Sounds good! The only question I have is about the official status of bigint. Is it officially in the spec such that it's appropriate to build on it? Is chrome the spec these days?

And yes, sorry, I didn't mean those were dependencies, just that they were analogous modules in the same general ecosystem that should talk coherently about types. I've created a quick branch here for typedarray-pool: https://github.com/rreusser/typedarray-pool/tree/bigint-support

@aschampion

Copy link
Copy Markdown
Contributor Author

BigInt status:

The spec has been in stage 3 for 2 years. It's been fairly stable for some time, though, and has been in Chrome for years and unflagged for quite some time. Chrome follows the spec. Consequently it's also in V8/Node since 10.4 (last June).

Firefox is strangely a straggler, but has been moving quickly recently, largely because the rust-wasm ecosystem (which is closely tied up with Firefox) uses BigInt heavily (wasm supports 64 bit integers). Last I checked, BigInt is available behind a flag in FF, but the typedarrays are a few releases away. Note that the MDN page doesn't even have the "experimental technology" warning banner that you find elsewhere. In general I would characterize the perception as wasm becoming production implies BigInt support.

It's also been in Opera for a year or so, making 3 people very happy I'm sure.

@aschampion

Copy link
Copy Markdown
Contributor Author

And thanks for the typedarray-pool patch!

@rreusser

rreusser commented Feb 21, 2019 •

Copy link
Copy Markdown
Member

Thanks for the details. PRified here: mikolalysenko/typedarray-pool#8

@mikolalysenko
mikolalysenko merged commit b82d833 into scijs:master Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

⌂ Proxy