You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
gh-40537: Simplify group generic algorithm
change a singleton set to a single element. The difference is that in
case of singleton set, the element's hash is computed then compared with
the pre-stored hash, but then both computing the hash and equality
checking is linear time.
not sure if it's an improvement. on the other hand the new
implementation works even when the type is not hashable.
edit: it's likely an improvement, for example with ZZ:
```
a = 3^floor(log(2, 3)*1000)
b = 5^floor(log(2, 5)*1000)
set_a = {a}
%timeit a == b # 32.4 ns
%timeit b in set_a # 106 ns
```
`==` can be done in sublinear time too if `==` exits early.
The second modification is to call discrete_log_lambda if ord=oo and
algorithm parameter is 'lambda' (the documentation says algorithm is
only used for prime order group, but discrete_log_lambda works either
way). Which makes more sense.
### 📝 Checklist
<!-- Put an `x` in all the boxes that apply. -->
- [ ] The title is concise and informative.
- [ ] The description explains in detail what this PR is about.
- [ ] I have linked a relevant issue or discussion.
- [ ] I have created tests covering the changes.
- [ ] I have updated the documentation and checked the documentation
preview.
### ⌛ Dependencies
<!-- List all open PRs that this PR logically depends on. For example,
-->
<!-- - #12345: short description why this is a dependency -->
<!-- - #34567: ... -->
URL: #40537
Reported by: user202729
Reviewer(s): Travis Scrimshaw
0 commit comments