GithubHelp home page GithubHelp logo

Can u explain for me, why do we need to use this library instead of using normal for loop ? i want to know about performance about lo HOT 2 OPEN

lamhieo02 avatar lamhieo02 commented on May 25, 2024
Can u explain for me, why do we need to use this library instead of using normal for loop ? i want to know about performance

from lo.

Comments (2)

ivila avatar ivila commented on May 25, 2024 1

Maybe you could check about the topic "Functional programming", it should answer your question about why people need this.

from lo.

x1unix avatar x1unix commented on May 25, 2024 1

@lamhieo02 it's more convenient to do complex processing in a declarative way using map/filter/reduce/flatmap chains.

Usually, this functionality uses the power of iterators to avoid unnecessary memory allocations, but this library (and JS as well) consumes and returns plain slices which leads to increased memory allocation.

It's possible to implement the same functionality with iterators (example), but as Go (yet) isn't designed with iterators in mind - you'll still need to transform a final result into a slice to use it in code which isn't familiar with iterators.

from lo.

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.