-
Notifications
You must be signed in to change notification settings - Fork 430
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
Use orjson + encoder #1876
base: master
Are you sure you want to change the base?
Use orjson + encoder #1876
Conversation
I think that we should make orjson mandatory. It would simplify the code and there seems no good reason not to do so. We are already going to include it in the Windows AIO and Mac bundle, and I have checked that all major Linux distributions include it. |
Yeah, I think you are right. Now that we can use it for all JSON load/dump, and it makes a big difference, it makes sense. |
I think we can make it mandatory, but still have a fallback to regular json.loads/dumps. That way if someone runs Gramps on some weird architecture (or orjson fails for some reason), it will still have access to your data. That seems prudent with genealogical data for the future. |
By keeping both json and orjson you are adding extra code to maintain and extra tests to run for very little gain. |
The next step is to remove to_json, from_json, to_dict, from_dict throughout the code base. Do you want me to do it in this PR, or a follow-up one? |
Co-authored-by: Nick Hall <[email protected]>
@Nick-Hall : |
OK. It looks like |
This reverts commit 9c6e227.
@Nick-Hall, I have a refactor for this PR, and to fix usage across the code base. Do you want me to make a PR on this PR, or add it to this PR? |
Please add it to this PR. |
@dsblank Thanks. Now we can review all the changes together as a whole. Please remember to add new files to either |
I think this is complete. I'll continue testing by using it |
I don't think that methods like data_to_object should optionally omit the obj_class parameter. As far as I can see, in most cases the object class is known when the method is called.
(I don't understand how the call In the return in the above method is resolved, presumably to the data_to_object imported from utils, but that is probably just my ignorance) |
This PR uses orjson with a hand-coded encoder/decoder everywhere, and assumes orjson is installed.
Tests shows that this is 60% faster than master for
db.iter_people()
on a 40k person table.