Giter Club home page Giter Club logo

Comments (6)

cuviper avatar cuviper commented on August 30, 2024 1
* BinopAssign<&int> for BigInt

I think this is the only one missing -- the rest should be covered by macro forwarding.

from num-bigint.

cuviper avatar cuviper commented on August 30, 2024

We shouldn't remove anything -- references can be a big saver when clones can be avoided. The assign ops should be implemented for references too.

from num-bigint.

lcnr avatar lcnr commented on August 30, 2024

I ran the test at my criterion.rs benchmark suite to check the influence of passing integers by reference instead of by value.

While I am currently running the tests with all integers instead of only u128, I still believe that passing by reference is actually not recommendable. There seems to be a non negligible performance hit when passing &u128 instead of u128.

tmp_data.txt

from num-bigint.

lcnr avatar lcnr commented on August 30, 2024

first bench this, by value
then this, by ref

don't have a lot of time right now, but by ref seems to mostly hurt the performance.

tmp_data.txt

from num-bigint.

cuviper avatar cuviper commented on August 30, 2024

Oh, yeah, I was only thinking of & among BigUint parameters. For primitive integers, it is a bit wasteful, but consistent with the std implementions. I think it's a matter of convenience for when you already have a reference. That case ought to be roughly equal for performance whether it's dereferenced before the operator or within, so it might as well be made easy for ergonomics.

from num-bigint.

lcnr avatar lcnr commented on August 30, 2024

I didn't know Add<&Self> is implemented for number types. 😮

So we should probably implemented the following binops for all integers to be similar to std:

  • Binop<BigInt> for int
  • Binop<&BigInt> for int
  • Binop<int> for BigInt
  • Binop<&int> for BigInt
  • Binop<int> for &BigInt
  • Binop<&int> for &BigInt
  • BinopAssign<int> for BigInt
  • BinopAssign<&int> for BigInt
  • BinopAssign<Bigint> for int
  • BinopAssign<&Bigint> for int

I might implement this if it is desired.

from num-bigint.

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.