In [237]: code = codes.HGPCode(codes.ClassicalCode.random(30, 25))
In [238]: %timeit code.old_get_logical_ops()
4.11 s ± 353 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)
In [239]: %timeit code.new_get_logical_ops()
258 ms ± 39.1 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)
Based on the construction in Section 4.1 of Gottesman's thesis.
Some benchmarking (with memoization turned off):