Git Product home page Git Product logo

Comments (5)

kgryte avatar kgryte commented on August 11, 2024 2

At this point, using Proxy is an absolute no-go. Wrapping an object in a Proxy automatically makes everything prohibitively slow, even if Proxy handlers are essentially no-ops. So, unfortunately, using Proxy is an interesting experiment, but likely to remain an experiment for the foreseeable future.

And, yes, for C-style multidimensional arrays, a Proxy handler must return a Proxy, which just compounds the problem. The more obvious approach would be to implement a slice syntax, but then you force string parsing for each element you access. In short, if performance is even remotely a concern, you will stick with the .get() method. If performance is not a concern (e.g., in a REPL environment), then using Proxy may be viable.

But what I can say is that in no shape or form will Proxy support be added to this package. If you want to do so, create a new package which wraps this one and hack a away.

from ndarray.

rajsite avatar rajsite commented on August 11, 2024 2

No problem! And thank y'all both for following up so quickly!

from ndarray.

rreusser avatar rreusser commented on August 11, 2024 1

Neat idea! I think the main caveat would be speed. I know @kgryte has benchmarked this recently and found proxies slow all property access (I think all. correct me if I'm wrong. this is a major distinction) down by about a factor of 15x, which is a bit prohibitive. Plus, to get multidimensional nesting, you'd need to allocate (or cache?) and then index those objects, which would no less than multiply the overhead by the number of dimensions. The numpy way is to vectorize everything and if single-element accessors are slow it's because you should've vectorized anyway. But then you get elaborate projects that compile python to c or do jit stuff, all to get around slow interpreted loops. It seems like a bit of a shame to go down that path, though I agree it would be otherwise pretty outstanding.

You might be interested in @kgryte's work on stdlib-js since he's really working hard on exploring and analyzing all of these possibilities and producing scientific-grade numerical software for js, both client-side and with wasm/native support. Here's the ndarray constructor docs, for example.

from ndarray.

rreusser avatar rreusser commented on August 11, 2024

I don't want you to think the suggestion isn't very much appreciated, @rajsite, but for now I'll close this since @kgryte is correct that this repo simply isn't the correct place for a different ndarray front-end. Don't hesitate to follow up though! Glad to discuss further.

from ndarray.

kgryte avatar kgryte commented on August 11, 2024

@rajsite If you are interested in benchmarks, you can run them locally, provided you have setup and configured a development environment. The requisite file containing the benchmarks can be found here. Eventually, these benchmarks will be accessible through the stdlib project website, once we regenerate the docs, and you'll be able to run them in your browser. In the meantime, to get hard data, the project development environment is the best means. Should you pursue to run them, don't hesitate to ping us on the stdlib Gitter channel, if you have questions.

from ndarray.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.