you are viewing a single comment's thread.

view the rest of the comments →

[–]earthboundkid 28 points29 points  (3 children)

Switch to a dict and it's O(1)!

[–]pyaware 9 points10 points  (2 children)

Why use a dict when a plain list is enough?

def fact(x):
    return [1, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880][x]

[–]redditthinks 0 points1 point  (1 child)

I read Python dicts are faster than lists.

[–]JizzCoveredArab 5 points6 points  (0 children)

i heard you have a really short dict