Giter Club home page Giter Club logo

Comments (4)

uyar avatar uyar commented on June 14, 2024 1

OK, I've made a few tries and made it all work as you have described and as expected according to the documentation for Python's decimal module. I wish generating decimals from floats had a nicer syntax in Python without having to use strings or rounding, but I can see why things are the way they are. Thanks!

from typedload.

uyar avatar uyar commented on June 14, 2024

This would be very nice. I'm in the process of redesigning the https://github.com/cinemagoer/cinemagoer (former imdbpy) code base (in https://github.com/cinemagoer/cinemagoerng) and I'm using typedload for deserialization. Great library, thank you very much! Anyway, movie ratings are given as floats but I believe decimal would be the proper type for that.

from typedload.

ltworf avatar ltworf commented on June 14, 2024

It's really really easy to do, but I haven't done it because it would mean importing them automatically even when they aren't used (most of the times, I guess).

Unless I think of a way of doing a conditional import, I don't think it's a good idea to just blindly import the module.

I think float is fine, I don't think you will need excessive precision for ratings.

Anyway you can pass strconstructed={decimal.Decimal} to support it.

This will override the default strconstructed set, so if you want to use also the types that are in there by default you must create the loader/dumper object and do like l.strconstructed.add(decimal.Decimal).

from typedload.

ltworf avatar ltworf commented on June 14, 2024

Unfortunately non-integer numbers and computers don't get so well together. I still think for your case you don't need that much precision and a float would be fine.

from typedload.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.