Optimization of expand in basic_modif.py
Making Expr immutable, and then optimize __hash__ with this
This commit is contained in:
parent
c27d706a26
commit
948e4da10c
6 changed files with 92 additions and 37 deletions
20
python_symb/IndependantTools/math_tools.py
Normal file
20
python_symb/IndependantTools/math_tools.py
Normal file
|
@ -0,0 +1,20 @@
|
|||
from __future__ import annotations
|
||||
from typing import *
|
||||
|
||||
|
||||
def gcd(a, b):
|
||||
"""
|
||||
Greatest common divisor
|
||||
work with any object that support modulo and comparison (contrary to math.gcd)
|
||||
|
||||
used in type : Fraction
|
||||
"""
|
||||
|
||||
if b > a:
|
||||
return gcd(b, a)
|
||||
|
||||
if b == 0:
|
||||
return a
|
||||
|
||||
return gcd(b, a % b)
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue