Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
gh-36173: Fix quadratic memory of berlekamp_massey
Fix #36172. Reduced berlekamp_massey memory consumption by replacing a dictionary with temporary variables. The memory consumption of the line highlighted below reduced from 42MB to 4MB (probably inaccurate, but significant enough). ```python from memory_profiler import profile from sage.matrix.berlekamp_massey import berlekamp_massey @Profile def gen_data(): p = random_prime(2**64) ls = [GF(p).random_element() for _ in range(20000)] berlekamp_massey(ls); # <--- this line gen_data() ``` I am not sure if I have to include extra doctests or not, or how to test memory consumptions, since the time complexity is also O(n^2). ### 📝 Checklist - [x] The title is concise, informative, and self-explanatory. - [x] The description explains in detail what this PR is about. - [x] I have linked a relevant issue or discussion. - [x] I have created tests covering the changes. - [x] I have updated the documentation accordingly. URL: #36173 Reported by: grhkm21 Reviewer(s): grhkm21, Kwankyu Lee
- Loading branch information