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

Add support for mutations #35

Merged
merged 10 commits into from
Aug 7, 2023
Merged

Add support for mutations #35

merged 10 commits into from
Aug 7, 2023

Conversation

saulshanabrook
Copy link
Member

This PR adds support for in-place operators in Python, by turning them into pure functions that return the mutated value.

@saulshanabrook saulshanabrook merged commit 3df7157 into main Aug 7, 2023
9 checks passed
@saulshanabrook saulshanabrook deleted the mutations branch August 7, 2023 19:29
saulshanabrook added a commit that referenced this pull request Aug 10, 2023
This PR makes reflected binary methods (i.e. `__radd__`) transparent,
so that they map directly to the non reflected versions.

This differs from the original implementation in #35 (which kept them as separate extensions).

That approach had a few flaws:

* The `str` representation of binary and non binary operators looked the same, which made them hard to debug. This could have been worked around by non pretty printing the reflective operators (i.e. keeping them as methods instead of operators).
* It was hard to define replacements for reflective operators, since they really only were activated on converted/non supported types.

This new method is a bit more magic, but should work for any expressions as long as their mathematical operators behave as one would
expect for the reversed versions.
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.

1 participant