Ad
  • Custom User Avatar

    It should be pointed out that it's only more performant across multiple executions within the same memory space. If all you care about is the runtime of one execution, then pyramidka's is almost twice as fast, even when x is 1.

    >>> factorial.lookup = []
    >>> f1(1)
    5.00679016113e-06
    >>> f2(1)
    9.05990600586e-06
    
    >>> factorial.lookup = []
    >>> f1(15000)
    0.0543911457062
    >>> f2(15000)
    0.101855039597```
    
  • Custom User Avatar

    Slightly inefficient to create the dict for each iteration of the comprehension.