Skip to content

Defer BigInt::clone() for new_int #1505

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

Merged
merged 1 commit into from
Oct 13, 2019

Conversation

youknowone
Copy link
Member

@youknowone youknowone commented Oct 10, 2019

This change will reduce useless BigInt::clone() for a few cases.

@@ -384,6 +384,17 @@ impl PyContext {
PyObject::new(PyInt::new(i), self.int_type(), None)
}

#[inline]
pub fn new_bigint(&self, i: &BigInt) -> PyObjectRef {
Copy link
Member Author

Choose a reason for hiding this comment

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

@coolreader18 Do you have any idea to integrate this function into new_int?

Copy link
Member

Choose a reason for hiding this comment

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

You could maybe declare your own trait and implement it for both T where T: Into<BigInt> + ToPrimitive and &T where T: Into<BigInt> + ToPrimitive. I think the real issue is that ToPrimitive should also be implemented by num-traits for &T where T: ToPrimitive.

Copy link
Member Author

@youknowone youknowone Oct 13, 2019

Choose a reason for hiding this comment

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

Thanks for the advice. But for now, I think I am not interested in working for trait puzzle.
I am sorry but would you review this PR as is again please?

@coolreader18
Copy link
Member

Sorry for merging #1502 too early, I guess you were still working on it.

@youknowone
Copy link
Member Author

That is ok. Actually, i thought it was done too. I am now doing a little refactoring and found related issues.

@coolreader18 coolreader18 merged commit d42d422 into RustPython:master Oct 13, 2019
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