-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add lookuptables
for writing efficient lookup tables; make symbolRank, symbolName O(1)
#18044
Conversation
lookuptables
for writing efficient lookup tables; make symbolRank, symbolName O(1)lookuptables
for writing efficient lookup tables; make symbolRank, symbolName O(1)
f1c1594
to
f421881
Compare
f421881
to
ada3678
Compare
|
because std/enumutils (itself used by std/jsonutils) depends on it, turning an O(N) API into O(1), and in future PRs other stdlib modules will depend on it. Note that the module is private for now (std/private/lookuptables).
|
There's a much simpler solution to |
the problem is not with ordinal enums (which don't need symbolRank), the problem is holey enums, for which your approach (which isn't really simpler btw) just cannot work efficiently (it'd be O(N) instead of O(1) as in this PR). And |
Please reread my proposal. It would work with holey enums and would be O(1) because afaik |
please read implementation of
|
I see, but then reprEnum should be improved instead of only improving symbolName/symbolRank. |
So why can't these improvements be applied to the tables module? |
The solution here is to move X out of the library as well - not introduce Y which soon will be used to motivate including A, B and C as well. |
If I literally just take his benchmark and impl and compile with Even if this lookuptables work did help (and my experiment above suggests it may well hurt), how many enum values are there usually? Is converting to strings in a fast & furious mode even common outside some json microbenchmark? Why is this an optimization so important that it needs a new table? In general, having the whole stdlib captive to any one person's json microbenchmarks seems like a truly terrible plan. |
This pull request has been automatically marked as stale because it has not had recent activity. If you think it is still a valid PR, please rebase it on the latest devel; otherwise it will be closed. Thank you for your contributions. |
O(1)
(follows jsonutils: add customization for toJson viaToJsonOptions
; generalize symbolName; add symbolRank #18029)EDIT
it works but don't review yet, i'm improving the API