Code Monkey home page Code Monkey logo

Comments (3)

neizod avatar neizod commented on September 28, 2024

the standard __getitem__ are design for list, so it need all 0 <= i < n exists in order to compute fibonacci at position n.

since position's algorithm see it as dictionary. i've try re-implement the InfiniteList as InfiniteDict to allowed the fibonacci use __getitem__ as native. this work flawlessly! but computation for many consecutive terms show significant time difference (sum up ~50k consecutive terms takes under 1 sec for old method, ~8 sec for the new one). so other approach shall be preferred.

from extmath.

neizod avatar neizod commented on September 28, 2024

testing n - len(fibonacci) >= large then choose subroutine should be avoid. since there might be the situation that ask for sum(fibonacci[i] for i in range(larger, largest)), its easily to see that if larger > large then every consecutive fibonacci[i] will be compute with the dictionary-way.

statistic analyse might be preferred to tell how much fibonacci[i] should be kept, and use dictionary-way after this no meter input n is.

from extmath.

neizod avatar neizod commented on September 28, 2024

just can't figure out how to achieve this, so done the __call__ way.

from extmath.

Related Issues (12)

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.