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-103509: PEP 697 -- Limited C API for Extending Opaque Types#103511

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
encukou merged 29 commits intopython:mainfromencukou:extend-opaque-sq
May 4, 2023

Conversation

encukou
Copy link
Member

@encukouencukou commentedApr 13, 2023
edited
Loading

PEP 697 describes the change. Some details it doesn't cover:

  • _PyHeapType_GET_MEMBERS is moved fromInclude/internal to the only.c file that uses it.
  • Tests demonstrate the API is usable for the purpose, and verify the layout with brutish-force.

TODO:

  • What's New entry
  • Fix thealignof &max_align_t

@encukouencukou marked this pull request as draftApril 13, 2023 15:01
@erlend-aaslanderlend-aasland self-requested a reviewApril 16, 2023 21:25
@encukou
Copy link
MemberAuthor

typeobject.c includes<stddef.h> and<stdalign.h>, which should definemax_align_t andalignof in C11. Yet, the Windows build complains:

D:\a\cpython\cpython\Objects\typeobject.c(3558,34): warning C4013: 'alignof' undefined; assuming extern returning int [D:\a\cpython\cpython\PCbuild\_freeze_module.vcxproj]D:\a\cpython\cpython\Objects\typeobject.c(3558,53): error C2065: 'max_align_t': undeclared identifier [D:\a\cpython\cpython\PCbuild\_freeze_module.vcxproj]

What am I missing?
@zooba, could you help?

(The reference I linked to listsalignof as removed in C23, which is a bit misleading. Themacro will be removed because it willbecome a keyword.)

@zooba
Copy link
Member

Looks like you needstdalign.h foralignof (defines thealignof macro to_Alignof), andmax_align_t only seems to exist for C++ viacstddef, where it's mapped todouble.

encukou reacted with thumbs up emoji

@encukou
Copy link
MemberAuthor

That means I can't usemax_align_t in CPython? Well, I can work around it.
But I was under the impression that MSVC did support C11. I can start the discussion to addmax_align_t (and possiblyalignof?) as exceptions to PEP 7. Do you know of any other C11 required features MSVC (or our configuration of it) doesn't support?

@encukouencukou marked this pull request as ready for reviewApril 20, 2023 08:52
@encukouencukou added the 🔨 test-with-buildbotsTest PR w/ buildbots; report in status section labelApr 20, 2023
@bedevere-bot
Copy link

🤖 New build scheduled with the buildbot fleet by@encukou for commitec9d5a8 🤖

If you want to schedule another build, you need to add the🔨 test-with-buildbots label again.

@bedevere-botbedevere-bot removed the 🔨 test-with-buildbotsTest PR w/ buildbots; report in status section labelApr 20, 2023
@encukouencukou marked this pull request as draftApril 20, 2023 09:41
@arhadthedev
Copy link
Member

The TraceRefs buildbot failure:

Modules/gcmodule.c:450: visit_decref: Assertion "!_PyObject_IsFreed(op)" failed
Enable tracemalloc to get the memory block allocation traceback

is likely caused bygh-103621.

Copy link
Member

@arhadthedevarhadthedev left a comment

Choose a reason for hiding this comment

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

void* cannot participate in address arithmetics. You need to cast bothdata_ptr andinstance tochar * to get distance in bytes.

encukou reacted with thumbs up emoji
@bedevere-bot
Copy link

🤖 New build scheduled with the buildbot fleet by@encukou for commit402ecc6 🤖

If you want to schedule another build, you need to add the🔨 test-with-buildbots label again.

@bedevere-botbedevere-bot removed the 🔨 test-with-buildbotsTest PR w/ buildbots; report in status section labelApr 27, 2023
Smaller objects might not be aligned to ALIGNOF_MAX_ALIGN_T.The offsets calculated for PEP 697 should be aligned, though.
@encukouencukou added the 🔨 test-with-buildbotsTest PR w/ buildbots; report in status section labelApr 28, 2023
@bedevere-bot
Copy link

🤖 New build scheduled with the buildbot fleet by@encukou for commitdb5d49b 🤖

If you want to schedule another build, you need to add the🔨 test-with-buildbots label again.

@bedevere-botbedevere-bot removed the 🔨 test-with-buildbotsTest PR w/ buildbots; report in status section labelApr 28, 2023
Copy link
Contributor

@erlend-aaslanderlend-aasland left a comment

Choose a reason for hiding this comment

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

Very nice!

Sorry for the late review; it took some time to dig through everything.

@encukou
Copy link
MemberAuthor

Thank you for the thorough review!
This should address the remaining comments.

erlend-aasland reacted with heart emoji

@encukouencukou requested a review fromarhadthedevMay 2, 2023 15:20
@erlend-aasland
Copy link
Contributor

erlend-aasland commentedMay 2, 2023
edited
Loading

Thanks! I've got some more comments, but we can deal with those in a follow-up PR if you think it's worth it. Let's land this before the feature freeze kicks in.

(I'm on mobile now; I won't be able to check the changes until tomorrow.)

encukou reacted with thumbs up emoji

Copy link
Member

@arhadthedevarhadthedev left a comment

Choose a reason for hiding this comment

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

Please, keep in mind that I neither participated in the PR discussion nor seen the PEP before. So I looked at the rendered docs in the same fashion as an outside user would do.

Here are three optional rough proposals and a forgotten full stop. However, they are non-binding suggestions that can be properly considered later, after 3.12b1 is out (otherwise the two remaining weeks will pass swiftly in the bikeshedding).

I've limited myself to the documentation because I have no expertise in the C API to check such a volume of code in such a short period of time.

Co-authored-by: Oleg Iarygin <oleg@arhadthedev.net>
Copy link
MemberAuthor

@encukouencukou left a comment

Choose a reason for hiding this comment

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

Thank you! Fresh eyes is exactly what the documentation needs.

It will also need a tutorial to bring the concepts together -- but when trying to write a tutorial, I keep finding rough edges that should be fixed first :)

@encukou
Copy link
MemberAuthor

Thanks for the reviews!

I'll merge, and leave the issues open for other PRs.

erlend-aasland and arhadthedev reacted with hooray emojierlend-aasland and arhadthedev reacted with rocket emoji

@encukouencukou merged commitcd9a56c intopython:mainMay 4, 2023
@encukouencukou deleted the extend-opaque-sq branchMay 4, 2023 07:56
@erlend-aasland
Copy link
Contributor

Thanks for the reviews!

I'll merge, and leave the issues open for other PRs.

Good job! This is a very nice feature.

encukou reacted with heart emoji

@encukou
Copy link
MemberAuthor

Thank you!

FWIW, here's a follow-up on thealignof(max_align_t):https://discuss.python.org/t/requiring-compilers-c11-standard-mode-to-build-cpython/26481

erlend-aasland reacted with eyes emoji

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@erlend-aaslanderlend-aaslanderlend-aasland left review comments

@arhadthedevarhadthedevarhadthedev approved these changes

@markshannonmarkshannonAwaiting requested review from markshannonmarkshannon is a code owner

@corona10corona10Awaiting requested review from corona10corona10 is a code owner

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

Successfully merging this pull request may close these issues.

5 participants
@encukou@zooba@bedevere-bot@arhadthedev@erlend-aasland

[8]ページ先頭

©2009-2025 Movatter.jp