Skip to content

Conversation

@TheAnyKey
Copy link
Contributor

This PR implements the bpo-39648 and bpo-39479, which are planned for CPython 3.9.

This change extends the math module to implement a lcm (least common multiple) function analog to the gcd. Further both functions are extended to take an arbitrary number of int arguments.

The kind of args is in accordance to the 3.9.a6 cpython implementation, although this style of parameters is quite uncommon in the math module; in similar cases iterables are used as arguments. Maybe this changes before release.

Further, I imported the test_math.py module from CPython and skipped all failing tests (unluckily there are plenty of them)

Whats missing: cpython also accepts object arguments having index implemented, this seems so far not be finalized in the reference. Thus I defer the implementation.

replace #1907

Copy link
Contributor

@palaviv palaviv left a comment

Choose a reason for hiding this comment

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

Very nice work. I have left a small suggestion that should remove a lot of code.
Would you mind adding a comment on tests that are related to 3.9 features? We currently aim for 3.8 and I would prefer people to have that data before trying to fix that. Another options is to get the tests of 3.8 instead of 3.9.


fn math_gcd(a: PyIntRef, b: PyIntRef) -> BigInt {
fn math_perf_arb_len_int_op<F>(
args: PyFuncArgs,
Copy link
Contributor

Choose a reason for hiding this comment

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

You can use here Args<PyIntRef>. Look at PySetInner::update for example. This will remove some of the argument parsing code.

Copy link
Contributor

@palaviv palaviv left a comment

Choose a reason for hiding this comment

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

Looks great. Thank you.

@palaviv palaviv merged commit 160afda into RustPython:master May 15, 2020
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.

2 participants