Skip to content

Simple fibonacci program doesn't finish execution #2445

@Sparkenstein

Description

@Sparkenstein

Report type: bug

I wrote a simple fibonacci series program that uses recursion as follows:

import time

def fib(n):
  if n == 1 or n == 0:
    return 1
  return fib(n - 1) + fib(n - 2)
t0 = time.time()
fib(35)
t1 = time.time()
print(f"{(t1 - t0) * 1000} ms")

on my machine, this program finishes in 230 ms on an average with CPython. but with rustpython it did not finish execution, I waited for 1 minute+ almost. my hardware specs are not that high-end but I believe if CPython can finish execution in 230ms, then rustpython should also finish it within seconds at least if not milliseconds.

note that it will run anything below value of 30. for n = 30, it took 16119.468450546265 ms i.e. 16s almost. which is a lot high but acceptable assuming rustpython is still in development stage

I am on Ubuntu 20, installed rustpython with cargo install so I am sure it's a release mode at least. my hardware is i5 4th gen with 8GB ram. let me know if you need anything else

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions