Giter VIP home page Giter VIP logo

Comments (3)

CrossEye avatar CrossEye commented on June 7, 2024

We're looking at (very soon) switching to manual currying of these internal functions for performance reasons. So, while that's an interesting idea, it may not be necessary.

On the other note, we are not trying to match the APIs of other libraries necessarily, or of the native prototypes, especially if what they have seems wrong or harmful. It's about the classic sorts of examples:

_.map(["1.1", "2.2", "3.3"], parseFloat); //=> [1.1, 2.2, 3.3]
_.map(["1", "2", "3"], parseInt); //=> [1, NaN, NaN]

Because Underscore.map (like the native Array.prototype.map) passes the index as the second parameter, but parseInt expects a radix.

R.map(parseFloat, ["1.1", "2.2", "3.3"]);  //=> [1.1, 2.2, 3.3]
R.map(parseInt, ["1", "2", "3"]); //=> [1, 2, 3]

Yes, we could clear this up with nAry or the newly added unary:

R.map.idx(R.unary(parseInt), ["1", "2", "3"]); //=> [1, 2, 3]

This feels the wrong direction to me for an FP library.

from ramda.

megawac avatar megawac commented on June 7, 2024

For max performance you will want to limit composition (currying requires wrapping thus a form of composition) while for terser code composition is great. Currying isn't needed to do most of the composition internally but will kill performance regardless of how well its tuned.

Currying the exposed API seperately is the best IMO

from ramda.

CrossEye avatar CrossEye commented on June 7, 2024

You can see what we did to where to reduce some of the overhead. The plan is to do this across the codebase. It will be uglier, but will gain performance for all users of the functions, not just internal users. So for instance:

var prop = function(name, obj) {
    return arguments.length === 0 ? 
           prop                   : 
           arguments.length < 2   ?
           function(obj) { return obj[name]; } : 
           obj[name];
};

You can see this in action at http://jsperf.com/ramda-auto-curry-cost/3

from ramda.

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.