mirror of
https://github.com/3b1b/manim.git
synced 2025-07-31 22:13:30 +08:00
Simple and small performance improvements
This commit is contained in:
@ -8,6 +8,17 @@ def sigmoid(x):
|
||||
return 1.0 / (1 + np.exp(-x))
|
||||
|
||||
|
||||
CHOOSE_CACHE = {}
|
||||
|
||||
|
||||
def choose_using_cache(n, r):
|
||||
if n not in CHOOSE_CACHE:
|
||||
CHOOSE_CACHE[n] = {}
|
||||
if r not in CHOOSE_CACHE[n]:
|
||||
CHOOSE_CACHE[n][r] = choose(n, r)
|
||||
return CHOOSE_CACHE[n][r]
|
||||
|
||||
|
||||
def choose(n, r):
|
||||
if n < r:
|
||||
return 0
|
||||
|
Reference in New Issue
Block a user