-
Notifications
You must be signed in to change notification settings - Fork 427
Add support for Python tuples to the Python module #26946
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
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Does handle `toPython` and `fromPython` yet, but does add the PyTuple type, as well as size and get methods for it (including a get method that takes a range) ---- Signed-off-by: Lydia Duncan <[email protected]>
Covers getting a tuple back from Python and calling get and size on it, including some error cases. More coverage is needed but I wanted a snapshot ---- Signed-off-by: Lydia Duncan <[email protected]>
Without adding the compilation error to this one, calls from it to the other version were reporting it as the line number instead of the user's context ---- Signed-off-by: Lydia Duncan <[email protected]>
I think I can improve `toTuple` but I want to save what I have first ---- Signed-off-by: Lydia Duncan <[email protected]>
This explicitly exercises toTuple and fromTuple ---- Signed-off-by: Lydia Duncan <[email protected]>
…nt it out Setter support for tuples is ... complicated. So we're going to punt on it for now. TODO: OPEN AN ISSUE FOR IT LYDIA ---- Signed-off-by: Lydia Duncan <[email protected]>
…emented Covers: - error case when converting the slice to an int - explicitly specifying PyTuple, homogeneous tuples, and PyList as the return type for the bounds case ---- Signed-off-by: Lydia Duncan <[email protected]>
… and get This means toTuple no longer needs to take its argument by in intent. ---- Signed-off-by: Lydia Duncan <[email protected]>
Covers: - homogeneous tuples - heterogeneous tuples - a tuple containing a list - tuples containing strings - a tuple containing bytes The fix in the previous commit helped the strings and bytes cases (the others were fine without it) ---- Signed-off-by: Lydia Duncan <[email protected]>
Covers: - 1 tuples - slices that should return 1 tuples - slicing with an empty range ---- Signed-off-by: Lydia Duncan <[email protected]>
---- Signed-off-by: Lydia Duncan <[email protected]>
---- Signed-off-by: Lydia Duncan <[email protected]>
jabraham17
reviewed
Mar 19, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left some comments about more potential edge cases, but this looks great!!
Covers: - Specifying too large of a Chapel tuple - Specifying too small of a Chapel tuple (where the latter is a future, see chapel-lang#26951) ---- Signed-off-by: Lydia Duncan <[email protected]>
---- Signed-off-by: Lydia Duncan <[email protected]>
… tests This was done based on the dicussion in chapel-lang#26951 ---- Signed-off-by: Lydia Duncan <[email protected]>
`Py_ssize_t` might be smaller than `int(64)` on 32 bit platforms, so use the max/min of the type we expect to use to avoid potential issues. Suggested by Jade, thanks! ---- Signed-off-by: Lydia Duncan <[email protected]>
---- Signed-off-by: Lydia Duncan <[email protected]>
---- Signed-off-by: Lydia Duncan <[email protected]>
jabraham17
approved these changes
Mar 21, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! thanks for making those changes
Thanks for noticing, Jade! ---- Signed-off-by: Lydia Duncan <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
[reviewed by @jabraham17]
Resolves Cray/chapel-private#7241
Add support for PyTuple. Covers:
Does not cover set as Python tuples are immutable, and the Python C interface only allows mutating a tuple if it knows it is the only one that owns the instance.
Adds a test of the new type and its methods, as well as extending the basicTypes correctness and memleaks tests to include it.
Passed a full paratest with futures