Merge pull request #3581 from ethereum/reduce-len-call

Optimization: reduce `len()` calls in `add_polynomialcoeff`
This commit is contained in:
Hsiao-Wei Wang 2024-01-20 14:32:13 +08:00 committed by GitHub
commit f1dff5f676
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 3 additions and 1 deletions

View File

@ -156,7 +156,9 @@ def add_polynomialcoeff(a: PolynomialCoeff, b: PolynomialCoeff) -> PolynomialCoe
Sum the coefficient form polynomials ``a`` and ``b``. Sum the coefficient form polynomials ``a`` and ``b``.
""" """
a, b = (a, b) if len(a) >= len(b) else (b, a) a, b = (a, b) if len(a) >= len(b) else (b, a)
return [(a[i] + (b[i] if i < len(b) else 0)) % BLS_MODULUS for i in range(len(a))] length_a = len(a)
length_b = len(b)
return [(a[i] + (b[i] if i < length_b else 0)) % BLS_MODULUS for i in range(length_a)]
``` ```
#### `neg_polynomialcoeff` #### `neg_polynomialcoeff`