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

Added num/malachite-bigint features #5131

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

h7kanna
Copy link

@h7kanna h7kanna commented Dec 16, 2023

As per the comment, #5130 (comment) added support for both num-bigint and malachite-bigint to fix #5130

Changes are tested on Mac and Ubuntu.
Some tests fail, but they also fail without these changes. So I assume these are flaky.

Note:

As the num-bigint and malachite-bigint are mutually exclusive features, care should be taken when changing things(deps) around. Most likely, adding 'default-features = false' will suffice.
This should be worthwhile as the malachite dependency is LGPL and it complicates licensing of any projects that embed RustPython.

Example usage:

rustpython-vm = { git = "https://github.com/h7kanna/rustpython", branch = "num-malachite-bigint-features", default-features = false, features = ["compiler", "serde", "num-bigint"]  }
rustpython = { git = "https://github.com/h7kanna/rustpython", branch = "num-malachite-bigint-features", default-features = false, features = ["num-bigint", "stdlib","threading"]}

Tests when num-bigint enabled

cargo test --workspace --exclude rustpython_wasm --no-default-features --features num-bigint,stdlib,threading

About CI:

Again as the features are mutually exclusive, CI workflow should be run with both enabled separately potentially doubling the run time. I added the 'malachite-bigint' in the workflow as it is the default and the default tests are successful

6 tests are failing when the 'num-bigint' is enabled, they need to be checked/fixed. That can be done in a separate PR if these changes are okay.

Also, we can refactor the code to use a separate crate 'rustpython-bigint' similar to https://github.com/RustPython/Parser/blob/main/format/src/bigint.rs

@h7kanna h7kanna changed the title Added num/malachite-bigint features [WIP] Added num/malachite-bigint features Dec 27, 2023
@h7kanna
Copy link
Author

h7kanna commented Dec 27, 2023

6 tests fail compared to malachite-bigint feature. Need to fix

287 tests OK.

6 tests failed:
    test_grp test_pathlib test_posixpath test_pwd test_shutil
    test_socket

10 tests skipped:
    test_compile test_ctypes test_devpoll test_epoll test_kqueue
    test_socketserver test_univnewlines test_urllib2net test_urllibnet
    test_zipfile64

num-bigint

281 tests OK.

12 tests failed:
    test_grp test_gzip test_long test_pathlib test_posixpath test_pwd
    test_shutil test_socket test_tarfile test_xmlrpc test_zipfile
    test_zlib

10 tests skipped:
    test_compile test_ctypes test_devpoll test_epoll test_kqueue
    test_socketserver test_univnewlines test_urllib2net test_urllibnet
    test_zipfile64

@h7kanna h7kanna changed the title [WIP] Added num/malachite-bigint features Added num/malachite-bigint features Dec 28, 2023
@h7kanna
Copy link
Author

h7kanna commented Dec 28, 2023

Hi @youknowone, this is ready for review.
Next CI run should pass all the default 'malachite-bigint' tests.
These are many changes, but rather mechanical. Mostly reverting this PR and adding features.

@youknowone
Copy link
Member

umm, so many cfg and features only for bigint.
@qingshi163 do you any idea we can do this better?

Copy link
Member

@youknowone youknowone left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't take this much complexity for bigint. My suggestion is creating rustpython-bigint in parser repository and make every crate to use it. Then each crate need to depending on it by feature. I believe we don't need to pass the bigint features to other sub crates in this case - because enabling both rustpython-bigint/malachite and rustpython-bigint/num will raise error.

@@ -472,6 +479,26 @@ impl PyFloat {
})
}

#[cfg(feature = "num-bigint")]
#[pymethod]
fn as_integer_ratio(&self, vm: &VirtualMachine) -> PyResult<(PyIntRef, PyIntRef)> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's happened for this function? was there incompatibility?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@h7kanna
Copy link
Author

h7kanna commented Dec 28, 2023

Yes, I agree. It is complex. I will make changes to create 'rustpython-bigint' crate.
This is just to make it work as I learn the codebase.

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.

Clarify license
2 participants