GithubHelp home page GithubHelp logo

kairucyrus / unnecessary-loop-avoidance Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 28 KB

Unnecessary loops can bring unintelligibility. Too much of something is always bad. Instead, it is advisable to take other paths (shorter or better) to approach the same problem.

Python 100.00%

unnecessary-loop-avoidance's Introduction

Unnecessary loops can lead to unintelligible code. It is therefore advisable to avoid them in all ways if possible. In our code(flat.py), we have two functions doing the same thing but differently. The second one seems to flatten our list seamlessly, by use of function itertools.chain. Comparing the two, the latter seems a better approach.

In our second code (std_dev_mean.py), we have two functions whose operational difference can be seen by close observation. In the first one, we go the long way in the calculation of mean and standard deviation for a given list(data) generated by use of list comprehension. The numpy module's functions for mean and standard deviation calculation seems to offer the take-route to avoid the for loop. Check the execution time for both functions. Avoid unnecessary loops in all ways possible.

unnecessary-loop-avoidance's People

Contributors

kairucyrus avatar

Watchers

 avatar

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.