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

Swap math.pow with self.pow #69

Merged
merged 1 commit into from
Aug 26, 2021
Merged

Swap math.pow with self.pow #69

merged 1 commit into from
Aug 26, 2021

Conversation

Sbozzolo
Copy link
Contributor

@Sbozzolo Sbozzolo commented Jul 29, 2021

Before this commit, pow was the only binary function that doesn't use the corresponding operator but calls pow in math. This commit defines a pow function that invokes the corresponding operator (**).

Using ** is preferable because it is slightly faster and preservers integers (see, https://www.semicolonworld.com/question/56223/exponentials-in-python-x-y-vs-math-pow-x-y).
Moreover, it improves type compatibility, since now the function works with user-defined classes (as long as they have a __pow__ method), math.pow only supports numbers.

Before this commit, `pow` was the only binary function that doesn't use the
corresponding operator but calls `pow` in `math`. This commit defines a `pow`
function that invokes the corresponding operator (**).

Using ** is preferable because it is slightly faster and preservers
integers (see,
https://www.semicolonworld.com/question/56223/exponentials-in-python-x-y-vs-math-pow-x-y).
Moreover, it improves type compatibility, since now the function works with
user-defined classes (as long as they have a __pow__ method), `math.pow` only
supports numbers.
@Sbozzolo
Copy link
Contributor Author

@cansadadeserfeliz, any thought of this?

@cansadadeserfeliz cansadadeserfeliz merged commit 46ae024 into axiacore:master Aug 26, 2021
@cansadadeserfeliz
Copy link
Contributor

@Sbozzolo thanks!

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