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

Split num into several crates #102

Closed
vks opened this issue Jun 8, 2015 · 16 comments
Closed

Split num into several crates #102

vks opened this issue Jun 8, 2015 · 16 comments
Assignees
Milestone

Comments

@vks
Copy link
Contributor

vks commented Jun 8, 2015

Currently num mixes functionality that IMHO should be separate:

  • bigints
  • generic traits (One, Zero, FromPrimitive, ToPrimitive, ...)
  • fractions
  • complex numbers
  • range*

The biggest offender are bigints, which are implemented very inefficiently. Real-world programs would probably rather use GMP or ramp.

The best plan of action would probably be creating the smaller crates and deprecating num?

@bluss
Copy link
Contributor

bluss commented Jul 10, 2015

The traits are probably the most used part and still the most lightweight, they should definitely be their own crate.

@vks
Copy link
Contributor Author

vks commented Sep 22, 2015

I think we should create a new crate for the traits and the fractions (and maybe for range*) and abandon num. For complex numbers there is stainless-steel/complex, for bigints there are fizyk20/rust-gmp and Aatch/ramp. All of those are superior to the corresponding functionality in num.

@cuviper
Copy link
Member

cuviper commented Oct 16, 2015

I agree these would be better separate. Really the only reason they're bundled is that num was a logical organization when they were all under the standard library, and they were pulled out en masse. Maybe now that we have the rust-num organization, we can start splitting them into specialized repos, leaving num as an umbrella crate for compatibility.

In defense of bigint, I think it's nice to have a library that's stable, universal, and pure-rust. Whereas rust-gmp depends on gmp, and ramp uses nightly features and arch-specific asm. It's ok with me that those are better than bigint in other ways, perhaps especially performance.

@kamalmarhubi
Copy link

I'd like to see the traits in their own crate as well.

@vks
Copy link
Contributor Author

vks commented Feb 11, 2016

To move this forward, we could extract the traits and publish a num_traits crate on crates.io.

@hauleth hauleth modified the milestone: v0.2.0 Feb 15, 2016
@hauleth hauleth self-assigned this Feb 16, 2016
kamalmarhubi added a commit to kamalmarhubi/num that referenced this issue Mar 3, 2016
kamalmarhubi added a commit to kamalmarhubi/num that referenced this issue Mar 3, 2016
kamalmarhubi added a commit to kamalmarhubi/num that referenced this issue Mar 3, 2016
This commit moves the traits module into its own crate. The new crate is
publicly imported so that downstream code will work without changes. New
code can choose to only depend on the traits crate.

Refs rust-num#102
homu added a commit that referenced this issue Apr 13, 2016
Move segments of library to separate crates

Issue #102

- [x] traits
- [x] bigint
- [x] integer
- [x] complex
- [x] iter
- [x] rational
@vks
Copy link
Contributor Author

vks commented Apr 29, 2016

This seems to be mostly done! The following function could still be moved to a sub crate crate: checked_pow, pow, abs_sub, sub, one, zero. Currently using them pulls in all crates, even if they are mostly not required.

@bluss
Copy link
Contributor

bluss commented Apr 29, 2016

one, zero are basically redundant now; A: Zero allows calling A::zero() which it did not do sometime before Rust 1.0 when this was designed.

@vks
Copy link
Contributor Author

vks commented Apr 29, 2016

Still, I they could be moved to num_traits. Removing them would be a breaking change.

@cuviper
Copy link
Member

cuviper commented Apr 29, 2016 via email

@vks
Copy link
Contributor Author

vks commented Apr 29, 2016

Where should pow and abs go? They are quite generic and work for floats and integers, and probably even matrices. A new sub crate?

@cuviper
Copy link
Member

cuviper commented Apr 29, 2016

Well abs is just a shell around Signed::abs, so that's fine going into num-traits.

pow is more generic, but I think logically we should keep it near checked_pow. I think it would be fine to put these into num-traits too, since that's the base of all num crates. It's also related to PrimInt::pow, though they aren't linked implementations.

vks added a commit to vks/num that referenced this issue May 10, 2016
vks added a commit to vks/num that referenced this issue May 13, 2016
@homu homu closed this as completed in #192 May 13, 2016
homu added a commit that referenced this issue May 13, 2016
Move functions remaining in num to num-traits

Fixes #102.
@vks
Copy link
Contributor Author

vks commented Jul 8, 2016

Since new functions have been added to num-traits, the version should probably be bumped to 0.2.

@cuviper
Copy link
Member

cuviper commented Jul 8, 2016 via email

@vks
Copy link
Contributor Author

vks commented Jul 8, 2016

I thought 0.1 -> 0.2 is for new functions, not for breaking changes. The problem is that to use the new functions in num_traits, you would have to specify 0.1.34 (whatever version when they were moved from num) in the Cargo.toml, which seems counterintuitive, because that's not how it is usually done. 0.2 suggests that new functions were added.

@cuviper
Copy link
Member

cuviper commented Jul 8, 2016

Cargo's semver has special treatment for leading zeros. 1.x to 1.y would be a compatible upgrade, usually just with added functionality like you say, but 0.x to 0.y is not considered compatible.

@vks
Copy link
Contributor Author

vks commented Jul 8, 2016

I see. I still think having to depend on 0.1.34 is confusing, but I guess it's ok if it adheres to Cargo's definition.

remexre pushed a commit to remexre/num that referenced this issue Jun 1, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants