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

Any plans to simplify customising float representation? #296

Open
jbasko opened this issue Apr 8, 2022 · 3 comments
Open

Any plans to simplify customising float representation? #296

jbasko opened this issue Apr 8, 2022 · 3 comments

Comments

@jbasko
Copy link

jbasko commented Apr 8, 2022

If one needs to change the representation of floats then they have to extend the encoder and override iterencode by copying over most of the code and just:

  1. replacing the _repr=FLOAT_REPR to something that they need.
  2. removing the C encoder option
@etrepum
Copy link
Member

etrepum commented Apr 8, 2022

No, this is not planned. Why would you want to do this?

@jbasko
Copy link
Author

jbasko commented Apr 8, 2022

Because I need to reproduce behaviour someone has borrowed from pandas to_json which they called with set double precision on float serialization. The code is used for hash calculation so pretty critical to repeat that silly behaviour.

@etrepum
Copy link
Member

etrepum commented Apr 8, 2022

That's a very unfortunate scenario, hashing a json encoded string is just asking for trouble. floats are printed at full double precision of course, but an optimal algorithm is used (the fewest digits that will round-trip through a correct parser exactly). The C extension can be disabled (globally), although this is more of a private implementation detail used by the test suite.

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

No branches or pull requests

2 participants