Skip to content
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

Build orjson for pyodide #1282

Closed
jmsmdy opened this issue Feb 24, 2021 · 11 comments
Closed

Build orjson for pyodide #1282

jmsmdy opened this issue Feb 24, 2021 · 11 comments

Comments

@jmsmdy
Copy link
Contributor

jmsmdy commented Feb 24, 2021

The project orjson offers significantly faster JSON encoding of objects than other Python packages (40x faster than the json package in many instances), with direct encoding of numpy arrays built in.

It would be nice if orjson could be built for pyodide. It is written in Rust, so that may be an issue.

@dalcde
Copy link
Contributor

dalcde commented Feb 24, 2021 via email

@spicy-sauce
Copy link
Contributor

spicy-sauce commented Apr 10, 2023

What's the status with this one? Not sure if it was handled or not as I'm getting:
ValueError: Can't find a pure Python 3 wheel for 'orjson<4.0.0,>=3.8.7'.

@hoodmane, I see that you took care of the Rust part, does it mean that the orjson package is just missing or is it something else?

Thanks

@hoodmane
Copy link
Member

It's probably straight forward. I'll look into it.

What's the difference between orjson and ujson? As I understand they are both rust json libs?

@spicy-sauce
Copy link
Contributor

Yes, both orjson and ujson are Rust libraries for working with JSON data, but they have some differences in terms of their features, performance, and use cases.

Features
orjson is a fast JSON serialization library that focuses on providing the best performance possible, but it does not provide all the features that some other JSON libraries offer, such as support for custom serialization or deserialization behavior. On the other hand, ujson is a more feature-rich JSON library that provides options for customizing serialization and deserialization behavior, including support for custom data types, but it may not be as optimized for performance as orjson.

Performance
orjson is known for its extremely fast serialization and deserialization performance, making it one of the fastest JSON libraries available in Rust. It uses a combination of optimized algorithms and low-level Rust optimizations to achieve its performance. ujson also offers good performance, but it may not be as fast as orjson in some cases.

Use cases
orjson is primarily designed for use cases where high-performance JSON serialization and deserialization are critical, such as in performance-sensitive applications or systems that require processing large amounts of JSON data with minimal overhead. ujson, on the other hand, may be more suitable for use cases that require a balance between performance and features, and where customization of serialization and deserialization behavior is desired.

Also see:
https://pythonspeed.com/articles/faster-json-library/

@hoodmane
Copy link
Member

Well it builds first try no problem.

@spicy-sauce
Copy link
Contributor

spicy-sauce commented Apr 11, 2023

@hoodmane Does it mean that you should pack it and place under packages?

@spicy-sauce
Copy link
Contributor

Can you please share the current status of this one? Thanks!

@hoodmane
Copy link
Member

hoodmane commented May 1, 2023

Well the status is that I think this is a straightforward task. I am currently distracted with other tasks, but if nobody else gets to it first I will get back to it at some point.

@spicy-sauce
Copy link
Contributor

@hoodmane, is it just adding a new package here with a corresponding meta.yaml file?
https://github.com/pyodide/pyodide/tree/main/packages

If so, I can try and push such a PR.

@hoodmane
Copy link
Member

hoodmane commented Aug 3, 2023

Yeah. You can use the Pyodide cli:

pyodide skeleton pypi orjson

will generate the appropriate files. Then you need to add test_orjson.py.

@ryanking13
Copy link
Member

Closing as resolved via #4036

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants