Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

GH-132554: "Virtual" iterators#132555

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
markshannon merged 29 commits intopython:mainfromfaster-cpython:virtual-iterators
May 27, 2025

Conversation

markshannon
Copy link
Member

@markshannonmarkshannon commentedApr 15, 2025
edited by bedevere-appbot
Loading

Just a draft PR until I have performance numbers.

@markshannon
Copy link
MemberAuthor

Performance is good. Nothing amazing, but a small speedup.

Stats show no significant changes

@Fidget-Spinner
Copy link
Member

@markshannon I don't think it matters here, but you didn't update inhttps://github.com/python/cpython/pull/132545/filesPy_TAG_BITS to3. It's still1. I know it "technically" doesn't matter because we use a bitshift to zero it out, but we should still update it to be consistent.

@markshannon
Copy link
MemberAuthor

@markshannon I don't think it matters here, but you didn't update inhttps://github.com/python/cpython/pull/132545/filesPy_TAG_BITS to3. It's still1. I know it "technically" doesn't matter because we use a bitshift to zero it out, but we should still update it to be consistent.

Fixed in#134244

static inline _PyStackRef
PyStackRef_IncrementTaggedIntNoOverflow(_PyStackRef ref)
{
assert(ref.bits != (uintptr_t)-1); // Deosn't overflow
Copy link
Member

Choose a reason for hiding this comment

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

I don't understand why you use this condition. Should it not beassert(ref.bits + 4 > ref.bits) or something like that?

markshannon reacted with thumbs up emoji
return PyCode_Check(PyStackRef_AsPyObjectBorrow(stackref));
}

static inline bool
PyStackRef_FunctionCheck(_PyStackRef stackref)
{
if (PyStackRef_IsTaggedInt(stackref)) {
return false;
}
return PyFunction_Check(PyStackRef_AsPyObjectBorrow(stackref));
}
Copy link
Member

Choose a reason for hiding this comment

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

Would it help to define these via a macro? Something like

#define STACKREF_CHECK_FUNC(T) \    static inline bool \    PyStackRef_ ## T ## Check(_PyStackRef stackref) \        if (PyStackRef_IsTaggedInt(stackref)) { \            return false; \        } \        return Py ## T ## _Check(PyStackRef_AsPyObjectBorrow(stackref)); \    }...STACKREF_CHECK_FUNC(Exception);STACKREF_CHECK_FUNC(Code);STACKREF_CHECK_FUNC(Function);

Choose a reason for hiding this comment

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

I think it might not work when want to define variants ofCheck andCheckExact, though we can always define two macros for that if we go down this route.

iterable doesn't prematurely free the iterable"""

def foo(x):
r = 0
Copy link
Member

Choose a reason for hiding this comment

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

I'd add this to make sure the test is testing what the comment is saying.
assert(sys.getrefcount(x) == 1)

_PyStackRef
PyStackRef_IncrementTaggedIntNoOverflow(_PyStackRef ref)
{
assert(ref.index != (uintptr_t)-1); // Overflow
Copy link
Member

Choose a reason for hiding this comment

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

Do here same as ind9dc597 ?

@markshannonmarkshannon merged commitf6f4e8a intopython:mainMay 27, 2025
72 checks passed
@markshannonmarkshannon deleted the virtual-iterators branchMay 27, 2025 14:59
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@Fidget-SpinnerFidget-SpinnerFidget-Spinner left review comments

@iritkatrieliritkatrieliritkatriel approved these changes

@ericsnowcurrentlyericsnowcurrentlyAwaiting requested review from ericsnowcurrentlyericsnowcurrently is a code owner

Assignees
No one assigned
Labels
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

3 participants
@markshannon@Fidget-Spinner@iritkatriel

[8]ページ先頭

©2009-2025 Movatter.jp