[mypyc] Use PyList_Check for isinstance(obj, list)#19416
Merged
JukkaL merged 3 commits intopython:masterfrom Jul 9, 2025
Merged
[mypyc] Use PyList_Check for isinstance(obj, list)#19416JukkaL merged 3 commits intopython:masterfrom
JukkaL merged 3 commits intopython:masterfrom
Conversation
JukkaL
reviewed
Jul 9, 2025
JukkaL
reviewed
Jul 9, 2025
mypyc/test-data/run-lists.test
Outdated
| class list: | ||
| pass | ||
|
|
||
| def test() -> None: |
Collaborator
There was a problem hiding this comment.
I don't think this gets executed, since the test runner looks for a test_ prefix. Also, can you merge the new test cases under one [case ...] and add multiple def test_... methods for sub test cases? Each top-level test case has significant constant overhead, so having a few, bigger test cases makes the test suite run faster.
mypyc/test-data/run-lists.test
Outdated
|
|
||
| [case testIsInstance] | ||
| from copysubclass import subc | ||
| def test() -> None: |
Collaborator
There was a problem hiding this comment.
Similar to my other comment about test_ prefix.
JukkaL
approved these changes
Jul 9, 2025
Collaborator
JukkaL
left a comment
There was a problem hiding this comment.
Thanks for the updates! Looks good now.
JukkaL
pushed a commit
that referenced
this pull request
Jul 11, 2025
Adding back a test for `next` with a list iterator as argument. Previously this test only checked if compilation succeeded so I have removed it in #19416, now it calls the test function and checks the result.
JukkaL
pushed a commit
that referenced
this pull request
Jul 15, 2025
Follow-up to #19416 adding primitives for `isinstance(obj, type)` where type is built-in.
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
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.
Added a primitive to translate
isinstance(obj, list)toPyList_Check(obj)instead ofPyObject_IsInstance(obj, type), as the former is faster. Similar primitives can be added for other built-in types, which I plan to do in next PRs.Using the above benchmark, execution time goes from ~1.4s to ~0.97s on my machine.