FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

[mypyc] feat: ForFilter generator helper for `builtins.filter` by BobTheBuidler · Pull Request #19643 · python/mypy · GitHub

Repository navigation

[mypyc] feat: ForFilter generator helper for builtins.filter - #19643

Open
BobTheBuidler wants to merge 51 commits into
python:masterfrom
BobTheBuidler:for-filter
Open

BobTheBuidler wants to merge 51 commits into
python:masterfrom
BobTheBuidler:for-filter

Conversation

BobTheBuidler commented Aug 12, 2025 •
edited
Loading

Copy link
Copy Markdown
Contributor

This PR adds a ForFilter helper class for for loops over builtins.filter which allows mypyc to maintain control of the function calling, so it can call native functions and use primitive ops, and to optimize filter's boolean check based on func's return value type

Comment thread mypyc/irbuild/for_helpers.py Outdated

Copy link
Copy Markdown
Contributor Author

Just realized I can extend this class to make it work for both builtins.filter and itertools.filterfalse with only 4 more LOC

I wouldn't think to make a primitive for iteration solely over itertools.filterfalse, but considering it would share the same object and only require one more boolean attribute, I think it makes sense to support here. What do you guys think?

BobTheBuidler changed the title [mypyc] feat: ForFilter generator helper for builtins.filter [mypyc] feat: ForFilter generator helper for builtins.filter Aug 12, 2025

Copy link
Copy Markdown
Contributor Author

I went ahead and implemented the above on a new branch here, we can merge it into this branch if we decide its worth special casing. I'd say it probably is, considering the code change is quite minimal change once we already have ForFilter defined.

Copy link
Copy Markdown
Contributor Author

I don't yet think the failing docs workflow is related to this PR, given that I only added a single bullet point to the native_operations.rst, though can't say for sure

JukkaL commented Sep 8, 2025

Copy link
Copy Markdown
Collaborator

Some tests are failing. Do yo need help with the failures?

BobTheBuidler commented Sep 8, 2025 •
edited
Loading

Copy link
Copy Markdown
Contributor Author

Yeah I could definitely use some help with this one, I'm not sure which recent change(s) caused this err nor what to do about it

Is this just another typeshed thing?

I also have one open question above from one of your review comments. I just tagged you in it to notify.

Comment thread mypyc/test-data/fixtures/ir.py Outdated
oh, whoops!

Co-authored-by: Brian Schubert <brianm.schubert@gmail.com>

Copy link
Copy Markdown
Contributor Author

Okay I've committed that change, once the tests finish the remaining IR errors should be related to the builder.accept comments above and will go away once we resolve that

Comment thread mypyc/irbuild/for_helpers.py Outdated
# from mypyc.irbuild.expression import transform_call_expr

# result = transform_call_expr(builder, fake_call_expr)
result = builder.accept(fake_call_expr)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I'm reverting this to its original state so the tests can turn green again. You'll see this as part of your review anyway.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants


Back | FazBrowse Home | New Git URL