Skip to content

Removes DjangoNumpyJSONEncoder (breaking change) - #26

Open
radusuciu wants to merge 1 commit into
brianjbuck:masterfrom
radusuciu:master
Open

Removes DjangoNumpyJSONEncoder (breaking change)#26
radusuciu wants to merge 1 commit into
brianjbuck:masterfrom
radusuciu:master

Conversation

@radusuciu

Copy link
Copy Markdown

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.
```
@brianjbuck
brianjbuck force-pushed the master branch 3 times, most recently from c8d3ecc to d6d3e0e Compare December 17, 2025 18:18
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