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

Removes DjangoNumpyJSONEncoder (breaking change) #26

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

radusuciu
Copy link

As suggested in #24, DjangoNumpyJSONEncoder should no longer be necessary when using orjson 3.3 or newer. This fixes an issue when this package is used with numpy 2.0, which has removed np.float_. However, since we'd be removing existing functionality, I think this has to be a breaking change. I did not update the version, but I guess this should probably mean going to 2.0.0.

@DanyilVoloshchuk, That would be a better solution than the original one proposed. You really shouldn't need it however since v3.3 orjson supports both numpy versions out of the box. That encoder was written before orjson supported numpy and only exists for some backwards compatibility before everyone upgraded orjson versions.

My preferred solution would be to remove the DjangoNumpyJSONEncoder entirely and have everyone migrate away from using that encoder. The docs could probably be more clear that developers should be using the orjson options instead:

REST_FRAMEWORK = {
    "ORJSON_RENDERER_OPTIONS": (
        orjson.OPT_SERIALIZE_NUMPY,
    ),
}

algitbot pushed a commit to alpinelinux/aports that referenced this pull request Oct 30, 2024
Adds brianjbuck/drf_orjson_renderer#26:

```
As suggested in #24, DjangoNumpyJSONEncoder should no longer be
necessary when using orjson 3.3 or newer. This fixes an issue when this
package is used with numpy 2.0, which has removed np.float_. However,
since we'd be removing existing functionality, I think this has to be a
breaking change. I did not update the version, but I guess this should
probably mean going to 2.0.0.
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant