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

New subclass payload layout#6319

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

Draft
youknowone wants to merge4 commits intoRustPython:main
base:main
Choose a base branch
Loading
fromyouknowone:new-subclass

Conversation

@youknowone
Copy link
Member

I am considering new subclass payload layout to provide

  1. Actually subclass typed function parameters, like using PyRef instead PyRef
  2. adding new fields to the subclass payload, which cause error right now.

I will left open questions on the code.

@coderabbitai
Copy link
Contributor

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the.coderabbit.yaml file in this repository. To trigger a single review, invoke the@coderabbitai review command.

You can disable this status message by setting thereviews.review_status tofalse in the CodeRabbit configuration file.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for usingCodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment@coderabbitai help to get the list of available commands and usage tips.

Comment on lines +92 to +94
#[inline]
fnpayload_type_id() -> std::any::TypeId{
std::any::TypeId::of::<PyInt>()
}
Copy link
MemberAuthor

@youknowoneyouknowoneDec 2, 2025
edited
Loading

Choose a reason for hiding this comment

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

This is okay here, because PyInt and PyBool shares same payload. The only difference is type.

But implementing this makesPyPayload::downcastable to be automaticallytrue for any kind ofPyInt. It doesn't make failing tests on this patch because we don't use that pattern. But it obviously will be a sort of trap for future developing.

Another question is thatPyPayload::downcastable only takes &PyObject currently. We can't compare it to actual type... because we don't have vm.ctx.

#[pyclass(name ="bool", module =false, base =PyInt)]
pubstructPyBool;
#[repr(transparent)]
pubstructPyBool(pubPyInt);
Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Now we have to manually define the base layout to be always leading field.
The problem is Rust actually only guarantees it to be actually same layout only when #[repr(transparent)] is used.

What I didn't check yet: Can using #[repr(C)] helps? Is there any other repr options to keep the first field as same as its original layout?

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

Reviewers

@coolreader18coolreader18Awaiting requested review from coolreader18

@ShaharNavehShaharNavehAwaiting requested review from ShaharNaveh

@arihant2matharihant2mathAwaiting requested review from arihant2math

At least 1 approving review is required to merge this pull request.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

1 participant

@youknowone

[8]ページ先頭

©2009-2025 Movatter.jp