Uh oh!
There was an error while loading. Please reload this page.
fix(types): render typed iterators in make_*iterator doc - #4876
Conversation
rwgk
left a comment
There was a problem hiding this comment.
Looks good to me. It's a very small change, based on what we have now.
rwgk
commented
Oct 16, 2023
FYI: I just initiated Google-global testing for this PR. Mainly to see how many stubgen-generated .pyi files need to be updated. BTW: When I deployed PRs #4831 & #4833 (in one combined update) I had to update 50 .pyi around the codebase, which was very unusual, but also not surprising (because #4833 changed |
rwgk
commented
Oct 17, 2023
I will have to update 2 .pyi files. I inspected the auto-generated changes and they look like a nice cleanup, e.g. - def keys(self) -> Iterator: ...- def values(self) -> Iterator: ...+ def keys(self) -> Iterator[str]: ...+ def values(self, *args, **kwargs) -> Any: ...- def __iter__(self) -> Iterator: ...+ def __iter__(self) -> Any: ...I'll go ahead with merging this PR. |
rwgk
commented
Oct 17, 2023
Note for completeness: The 🐍 3.9-dbg (deadsnakes) • Valgrind • x64 CI failure is unrelated. First observed 2023-10-16 (yesterday). |
sizmailov
commented
Oct 18, 2023
@rwgk Thank you! TBH I expected more files to be affected. Probably Google's code base does not expose many iterators. The diff doesn't look like a 100% improvement to me. The following stub got worse, but it's an issue of binding code, not pybind11. - def values(self) -> Iterator: ...+ def values(self, *args, **kwargs) -> Any: ...I would speculate that the snippet was generated by an older version of I have no good guess what happened to |
Oof ... I was looking at it wrong, thanks for pointing out that this went the wrong way. According to metadata that are usually very reliable we're using mypy at this commit: That's from Aug 11, 2023, just 2 months ago. This is what the Could it be that |
sizmailov
commented
Oct 18, 2023
The C++ signatures in docstrings should be fixed on the binding code side: I don't how Yes, |
rwgk
commented
Oct 18, 2023
Thanks for the pointer. I'll relay that to the owners of the code. |
rwgk
commented
Oct 18, 2023
It's coming straight back at me like a boomerang:
What could we do there (in pybind11/pybind11.h)? |
sizmailov
commented
Oct 19, 2023
What I believe it should be fixed on the If we are talking about fixing |
rwgk
commented
Oct 19, 2023
@sizmailov wrote:
That's not possible: the Python name is not known at compile time ( After turning this over in my mind, discarding several ideas, and asking my team mates for advice, I landed on this: It's probably best to continue the discussion there. |
make_*iterator docmake_*iterator docSkylion007
commented
Jan 14, 2024
We should have added the test from this issue: #4100 Can we verify we did not accidentally reintroduce this problem? |
Description
Render typed iterators for
make_iterator,make_key_iterator,make_value_iterator.Example:
The benchmark shows no measurable differences in runtime performance.
bench.py
The module size is increased by 8192 bytes (~0.2%):
Previous attempts to address the same issue:
#2244
#2371
Suggested changelog entry: