Title: Add math.fib() generator
Type: enhancement Stage: resolved
Components: Library (Lib) Versions: Python 3.9
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: Nosy List: lovi, mark.dickinson, rhettinger, stutzbach
Priority: normal Keywords:

Created on 2019-12-14 04:43 by lovi, last changed 2019-12-14 05:10 by rhettinger. This issue is now closed.

Messages (2)
msg358375 - (view) Author: Lovi (lovi) Date: 2019-12-14 04:43
I think it's appropriate to add the generator fib() to the math module. With fib(), some operations will be easier.

The generator is like this:

def fib(count=None):
    if count is not None and not isinstance(count, int):
        raise ValueError(f"Parameter count has an unexpected type: {count.__class__.__name__}.")
    a, b = 0, 1
    while True:
        a, b = b, a + b
        if count is not None:
            if not count:
            count -= 1
        yield a
msg358377 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2019-12-14 05:10
Sorry, this isn't sufficiently useful or needed to warrant inclusion in the standard library.
Date User Action Args
2019-12-14 05:10:44rhettingersetstatus: open -> closed
resolution: rejected
messages: + msg358377

stage: resolved
2019-12-14 04:47:41xtreaksetnosy: + rhettinger, mark.dickinson, stutzbach
2019-12-14 04:43:56lovicreate