GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Add macro for type check functions in c-api by bschoenmaeckers · Pull Request #7871 · RustPython/RustPython

Conversation

@bschoenmaeckers

@bschoenmaeckers bschoenmaeckers commented May 13, 2026 •
edited by coderabbitai Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • New Features
    • Added exported C API functions providing runtime type checks (exact-type and subtype checks) for extension modules.
    • Introduced a C-accessible subtype query to inspect type relationships between runtime types.
    • Expanded interoperability surface for extensions performing type inspections and comparisons.

Review Change Stack

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bschoenmaeckers bschoenmaeckers changed the title Add macro for type check function in c-api Add macro for type check functions in c-api May 13, 2026
@coderabbitai

coderabbitai Bot commented May 13, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

Run ID: c7fad624-873f-4cf8-8222-9dd4250cc2d6

📥 Commits

Reviewing files that changed from the base of the PR and between 69b9f04 and cc1455b.

📒 Files selected for processing (1)
  • crates/capi/src/object.rs
🚧 Files skipped from review as they are similar to previous changes (1)
  • crates/capi/src/object.rs

📝 Walkthrough

Walkthrough

Adds a macro-generated pair of C-exported functions PyType_Check (subtype) and PyType_CheckExact (exact match), plus PyType_IsSubtype(a, b); all run their checks inside with_vm and return results as c_int.

Changes

Type-checking C API exports

Layer / File(s) Summary
Type-checking and type relationship functions
crates/capi/src/object.rs
define_py_check! macro defines PyType_Check and PyType_CheckExact to run subtype/exact checks against vm.ctx.types.type_type inside with_vm; PyType_IsSubtype dereferences *const PyTypeObject inputs, calls a.is_subtype(b) inside with_vm, and returns a c_int result.

Sequence Diagram(s)

sequenceDiagram
  participant Caller
  participant with_vm
  participant vm_ctx_types_type_type
  participant PyTypeObject
  Caller->>with_vm: call PyType_Check(obj) / PyType_CheckExact(obj)
  with_vm->>vm_ctx_types_type_type: compare obj.type against ctx.types.type_type
  Caller->>with_vm: call PyType_IsSubtype(a, b)
  with_vm->>PyTypeObject: call a.is_subtype(b)
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested reviewers

  • youknowone

Poem

🐰 I hopped through vm's cozy den,
Peeked at types and then again,
Exact or subtype — a tiny quest,
Returned a number, passed the test,
Hooray, C calls now know the rest!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding a macro for type check functions in the C API, which aligns with the introduction of define_py_check! macro and the three exported type-checking functions.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

❤️ Share
  • X
  • Mastodon
  • Reddit
  • LinkedIn

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

youknowone
youknowone requested changes May 14, 2026
View reviewed changes

@youknowone youknowone left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

👍

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread crates/capi/src/object.rs Resolved

Uh oh!

There was an error while loading. Please reload this page.

@bschoenmaeckers
bschoenmaeckers force-pushed the c-api-type-check branch from 091172f to dc6d7eb Compare May 16, 2026 11:11
@bschoenmaeckers bschoenmaeckers mentioned this pull request May 16, 2026
Convert type check macro's to functions on the limited api capi-workgroup/decisions#105
Open
@bschoenmaeckers
bschoenmaeckers force-pushed the c-api-type-check branch from dc6d7eb to 69b9f04 Compare May 16, 2026 18:29
bschoenmaeckers added 2 commits May 17, 2026 13:34
@bschoenmaeckers
Add macro for type check function in c-api
f5f25ff
@bschoenmaeckers
Add fn to macro
cc1455b
@bschoenmaeckers
bschoenmaeckers force-pushed the c-api-type-check branch from 69b9f04 to cc1455b Compare May 17, 2026 11:34
@bschoenmaeckers

bschoenmaeckers commented May 17, 2026

Copy link
Copy Markdown
Contributor Author

@youknowone This is also ready to be merged!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

youknowone
youknowone approved these changes May 17, 2026
View reviewed changes

@youknowone youknowone left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Thank you for reminding!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@youknowone
youknowone enabled auto-merge (squash) May 17, 2026 11:53
@youknowone
youknowone merged commit a1a87dc into RustPython:main May 17, 2026
26 checks passed

Uh oh!

There was an error while loading. Please reload this page.

This was referenced May 17, 2026
Add unicode & bytes c-api support #7904
Merged
Add integer c-api support #7905
Merged
Add tuple support to c-api #7907
Merged
@bschoenmaeckers
bschoenmaeckers deleted the c-api-type-check branch May 18, 2026 15:51
This was referenced May 18, 2026
Add more c-api error functions #7915
Merged
Add type name c-api functions #7925
Merged
Add basic dict function to c-api #7929
Merged
Add bool support to c-api #7938
Merged
Add float support to c-api #7943
Merged
This was referenced May 26, 2026
Add list support to c-api #7944
Merged
Add set object functions to c-api #8002
Merged
@coderabbitai coderabbitai Bot mentioned this pull request Jun 4, 2026
Add more object functions to c-api #8042
Merged
@coderabbitai coderabbitai Bot mentioned this pull request Jul 7, 2026
Move type c-api functions #8233
Merged
youknowone pushed a commit that referenced this pull request Sep 16, 2026
@bschoenmaeckers
Add macro for type check functions in c-api (#7871)
4f49bda
* Add macro for type check function in c-api

* Add `fn` to macro
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@youknowone youknowone youknowone approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@bschoenmaeckers @youknowone
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.