René's URL Explorer Experiment


Title: Allow c functions in tp_new type slot by bschoenmaeckers · Pull Request #8346 · RustPython/RustPython · GitHub

Open Graph Title: Allow c functions in tp_new type slot by bschoenmaeckers · Pull Request #8346 · RustPython/RustPython

X Title: Allow c functions in tp_new type slot by bschoenmaeckers · Pull Request #8346 · RustPython/RustPython

Description: This is my first draft of allowing C functions in type slots. I started with the NewFunc slot and would love some feedback on my approach before converting the other slots. @youknowone Could you please share your opinion. Summary by CodeRabbit Bug Fixes Improved __new__ constructor dispatch across built-in types (bool, int, float, str, tuple, set) by invoking the resolved constructor target more reliably. Refined the “same/equivalent constructor” detection used for __init fast-path specialization, improving when the optimized path is selected. Improved handling of Rust-backed __new__ wrappers and inherited constructor behavior for classes/types. Compatibility Standardized constructor wiring to support consistent Rust-backed behavior and lay groundwork for additional native __new__ variants.

Open Graph Description: This is my first draft of allowing C functions in type slots. I started with the NewFunc slot and would love some feedback on my approach before converting the other slots. @youknowone Could you pl...

X Description: This is my first draft of allowing C functions in type slots. I started with the NewFunc slot and would love some feedback on my approach before converting the other slots. @youknowone Could you pl...

Opengraph URL: https://github.com/RustPython/RustPython/pull/8346

X: @github

direct link

Domain: github.com

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:31d63ab9-2154-a87b-b51e-7938d3fe68cf
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idDB4E:785A9:3ABE293:4A914DA:6B01FE55
html-safe-nonce9b29fafac3783a63daf7ce5231648a373621224d7228fee3c825e246791f8d93
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEQjRFOjc4NUE5OjNBQkUyOTM6NEE5MTREQTo2QjAxRkU1NSIsInZpc2l0b3JfaWQiOiI1OTUxNzYwNTkxNjA4NzQxNDYxIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmac894e500f3c9c2a774a8077da6c033ef98062471651ccc2f368692906a7dc0388
hovercard-subject-tagpull_request:4101108619
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/RustPython/RustPython/pull/8346/files
twitter:imagehttps://avatars.githubusercontent.com/u/7943856?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/7943856?s=400&v=4
og:image:altThis is my first draft of allowing C functions in type slots. I started with the NewFunc slot and would love some feedback on my approach before converting the other slots. @youknowone Could you pl...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/RustPython/RustPython git https://github.com/RustPython/RustPython.git
octolytics-dimension-user_id39710557
octolytics-dimension-user_loginRustPython
octolytics-dimension-repository_id135201145
octolytics-dimension-repository_nwoRustPython/RustPython
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id135201145
octolytics-dimension-repository_network_root_nwoRustPython/RustPython
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release423dbb54c5e7bfecc838eb387c1435eb3d0e760d
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/RustPython/RustPython/pull/8346/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FRustPython%2FRustPython%2Fpull%2F8346%2Ffiles
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FRustPython%2FRustPython%2Fpull%2F8346%2Ffiles
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=RustPython%2FRustPython
Reloadhttps://github.com/RustPython/RustPython/pull/8346/files
Reloadhttps://github.com/RustPython/RustPython/pull/8346/files
Reloadhttps://github.com/RustPython/RustPython/pull/8346/files
RustPythonhttps://github.com/RustPython
RustPythonhttps://github.com/RustPython/RustPython
Codehttps://github.com/RustPython/RustPython
Issues195 (195)https://github.com/RustPython/RustPython/issues
Pull requests133 (133)https://github.com/RustPython/RustPython/pulls
Discussionshttps://github.com/RustPython/RustPython/discussions
Actionshttps://github.com/RustPython/RustPython/actions
Projectshttps://github.com/RustPython/RustPython/projects
Wikihttps://github.com/RustPython/RustPython/wiki
Security and qualityhttps://github.com/RustPython/RustPython/security
Insightshttps://github.com/RustPython/RustPython/insights
Sign up for GitHub https://github.com/signup?return_to=%2FRustPython%2FRustPython%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2FRustPython%2FRustPython%2Fissues%2Fnew%2Fchoose
bschoenmaeckershttps://github.com/bschoenmaeckers
RustPython:mainhttps://github.com/RustPython/RustPython/tree/main
bschoenmaeckers:c-api-type-slotshttps://github.com/bschoenmaeckers/RustPython/tree/c-api-type-slots
Conversation 12 https://github.com/RustPython/RustPython/pull/8346
Commits 1 https://github.com/RustPython/RustPython/pull/8346/commits
Checks 0 https://github.com/RustPython/RustPython/pull/8346/checks
Files changed https://github.com/RustPython/RustPython/pull/8346/files
Please reload this pagehttps://github.com/RustPython/RustPython/pull/8346/files
Allow c functions in tp_new type slot https://github.com/RustPython/RustPython/pull/8346/files#top
Show all changes 1 commit https://github.com/RustPython/RustPython/pull/8346/files
8c53827 Allow c functions in tp_new type slot bschoenmaeckers Jul 21, 2026 https://github.com/RustPython/RustPython/pull/8346/commits/8c53827626316aade37491a08f6c28cfc552c228
Clear filters https://github.com/RustPython/RustPython/pull/8346/files
Please reload this pagehttps://github.com/RustPython/RustPython/pull/8346/files
Please reload this pagehttps://github.com/RustPython/RustPython/pull/8346/files
pyclass.rs https://github.com/RustPython/RustPython/pull/8346/files#diff-26c99b2025ccb53d8e726042a48a5886526d898281c27735bd1b6ebd51e55feb
bool.rs https://github.com/RustPython/RustPython/pull/8346/files#diff-031937242c4d43a8be44d7ac3ea19c674fbf586f50ff02f22e7f6e19a4dd63a4
float.rs https://github.com/RustPython/RustPython/pull/8346/files#diff-4deb5676286995e76a9c87099407a5d64a7a57a6ee9ca97a059e79e649bc0dca
int.rs https://github.com/RustPython/RustPython/pull/8346/files#diff-6f6fb35904d4bdd7481e9d90622e7fc41a1eff225053e762f724150581464887
set.rs https://github.com/RustPython/RustPython/pull/8346/files#diff-ca3250b43726cb4327f8b4f6d413151036abc2f00f7c3197f55432013ca2c07f
str.rs https://github.com/RustPython/RustPython/pull/8346/files#diff-a04ea1f7734fe40189e756196e034e6dedfcd5c82f2925e58cfd51ba7432073a
tuple.rs https://github.com/RustPython/RustPython/pull/8346/files#diff-606274a9a62c77c00f802fbc298be35b47e2932cf90cc413748b4d8fc69d7c7e
type.rs https://github.com/RustPython/RustPython/pull/8346/files#diff-fb88962f9343ca7b8d31bfe34f5063136575e05eadae6fccb3b64658e14b0d6c
class.rs https://github.com/RustPython/RustPython/pull/8346/files#diff-ea8866550ea2830f83d804b5bc2a03456c7eaa2308b786b0aa71a984ca25b8fe
frame.rs https://github.com/RustPython/RustPython/pull/8346/files#diff-03f2741d7d424014f3d2f0c82226be52fa58134aab34bf0780714ee67a248deb
slot.rs https://github.com/RustPython/RustPython/pull/8346/files#diff-1b5587c15bdfe9ff552fbc35e014eef20d6b7934fbb31b922cf35d87e8837b7b
crates/derive-impl/src/pyclass.rshttps://github.com/RustPython/RustPython/pull/8346/files#diff-26c99b2025ccb53d8e726042a48a5886526d898281c27735bd1b6ebd51e55feb
View file https://github.com/bschoenmaeckers/RustPython/blob/8c53827626316aade37491a08f6c28cfc552c228/crates/derive-impl/src/pyclass.rs
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/RustPython/RustPython/pull/8346/{{ revealButtonHref }}
https://github.com/RustPython/RustPython/pull/8346/files#diff-26c99b2025ccb53d8e726042a48a5886526d898281c27735bd1b6ebd51e55feb
https://github.com/RustPython/RustPython/pull/8346/files#diff-26c99b2025ccb53d8e726042a48a5886526d898281c27735bd1b6ebd51e55feb
https://github.com/RustPython/RustPython/pull/8346/files#diff-26c99b2025ccb53d8e726042a48a5886526d898281c27735bd1b6ebd51e55feb
https://github.com/RustPython/RustPython/pull/8346/files#diff-26c99b2025ccb53d8e726042a48a5886526d898281c27735bd1b6ebd51e55feb
crates/vm/src/builtins/bool.rshttps://github.com/RustPython/RustPython/pull/8346/files#diff-031937242c4d43a8be44d7ac3ea19c674fbf586f50ff02f22e7f6e19a4dd63a4
View file https://github.com/bschoenmaeckers/RustPython/blob/8c53827626316aade37491a08f6c28cfc552c228/crates/vm/src/builtins/bool.rs
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/RustPython/RustPython/pull/8346/{{ revealButtonHref }}
https://github.com/RustPython/RustPython/pull/8346/files#diff-031937242c4d43a8be44d7ac3ea19c674fbf586f50ff02f22e7f6e19a4dd63a4
https://github.com/RustPython/RustPython/pull/8346/files#diff-031937242c4d43a8be44d7ac3ea19c674fbf586f50ff02f22e7f6e19a4dd63a4
crates/vm/src/builtins/float.rshttps://github.com/RustPython/RustPython/pull/8346/files#diff-4deb5676286995e76a9c87099407a5d64a7a57a6ee9ca97a059e79e649bc0dca
View file https://github.com/bschoenmaeckers/RustPython/blob/8c53827626316aade37491a08f6c28cfc552c228/crates/vm/src/builtins/float.rs
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/RustPython/RustPython/pull/8346/{{ revealButtonHref }}
https://github.com/RustPython/RustPython/pull/8346/files#diff-4deb5676286995e76a9c87099407a5d64a7a57a6ee9ca97a059e79e649bc0dca
https://github.com/RustPython/RustPython/pull/8346/files#diff-4deb5676286995e76a9c87099407a5d64a7a57a6ee9ca97a059e79e649bc0dca
crates/vm/src/builtins/int.rshttps://github.com/RustPython/RustPython/pull/8346/files#diff-6f6fb35904d4bdd7481e9d90622e7fc41a1eff225053e762f724150581464887
View file https://github.com/bschoenmaeckers/RustPython/blob/8c53827626316aade37491a08f6c28cfc552c228/crates/vm/src/builtins/int.rs
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/RustPython/RustPython/pull/8346/{{ revealButtonHref }}
https://github.com/RustPython/RustPython/pull/8346/files#diff-6f6fb35904d4bdd7481e9d90622e7fc41a1eff225053e762f724150581464887
https://github.com/RustPython/RustPython/pull/8346/files#diff-6f6fb35904d4bdd7481e9d90622e7fc41a1eff225053e762f724150581464887
crates/vm/src/builtins/set.rshttps://github.com/RustPython/RustPython/pull/8346/files#diff-ca3250b43726cb4327f8b4f6d413151036abc2f00f7c3197f55432013ca2c07f
View file https://github.com/bschoenmaeckers/RustPython/blob/8c53827626316aade37491a08f6c28cfc552c228/crates/vm/src/builtins/set.rs
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/RustPython/RustPython/pull/8346/{{ revealButtonHref }}
https://github.com/RustPython/RustPython/pull/8346/files#diff-ca3250b43726cb4327f8b4f6d413151036abc2f00f7c3197f55432013ca2c07f
https://github.com/RustPython/RustPython/pull/8346/files#diff-ca3250b43726cb4327f8b4f6d413151036abc2f00f7c3197f55432013ca2c07f
crates/vm/src/builtins/str.rshttps://github.com/RustPython/RustPython/pull/8346/files#diff-a04ea1f7734fe40189e756196e034e6dedfcd5c82f2925e58cfd51ba7432073a
View file https://github.com/bschoenmaeckers/RustPython/blob/8c53827626316aade37491a08f6c28cfc552c228/crates/vm/src/builtins/str.rs
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/RustPython/RustPython/pull/8346/{{ revealButtonHref }}
https://github.com/RustPython/RustPython/pull/8346/files#diff-a04ea1f7734fe40189e756196e034e6dedfcd5c82f2925e58cfd51ba7432073a
https://github.com/RustPython/RustPython/pull/8346/files#diff-a04ea1f7734fe40189e756196e034e6dedfcd5c82f2925e58cfd51ba7432073a
crates/vm/src/builtins/tuple.rshttps://github.com/RustPython/RustPython/pull/8346/files#diff-606274a9a62c77c00f802fbc298be35b47e2932cf90cc413748b4d8fc69d7c7e
View file https://github.com/bschoenmaeckers/RustPython/blob/8c53827626316aade37491a08f6c28cfc552c228/crates/vm/src/builtins/tuple.rs
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/RustPython/RustPython/pull/8346/{{ revealButtonHref }}
https://github.com/RustPython/RustPython/pull/8346/files#diff-606274a9a62c77c00f802fbc298be35b47e2932cf90cc413748b4d8fc69d7c7e
https://github.com/RustPython/RustPython/pull/8346/files#diff-606274a9a62c77c00f802fbc298be35b47e2932cf90cc413748b4d8fc69d7c7e
crates/vm/src/builtins/type.rshttps://github.com/RustPython/RustPython/pull/8346/files#diff-fb88962f9343ca7b8d31bfe34f5063136575e05eadae6fccb3b64658e14b0d6c
View file https://github.com/bschoenmaeckers/RustPython/blob/8c53827626316aade37491a08f6c28cfc552c228/crates/vm/src/builtins/type.rs
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/RustPython/RustPython/pull/8346/{{ revealButtonHref }}
https://github.com/RustPython/RustPython/pull/8346/files#diff-fb88962f9343ca7b8d31bfe34f5063136575e05eadae6fccb3b64658e14b0d6c
https://github.com/RustPython/RustPython/pull/8346/files#diff-fb88962f9343ca7b8d31bfe34f5063136575e05eadae6fccb3b64658e14b0d6c
https://github.com/RustPython/RustPython/pull/8346/files#diff-fb88962f9343ca7b8d31bfe34f5063136575e05eadae6fccb3b64658e14b0d6c
https://github.com/RustPython/RustPython/pull/8346/files#diff-fb88962f9343ca7b8d31bfe34f5063136575e05eadae6fccb3b64658e14b0d6c
https://github.com/RustPython/RustPython/pull/8346/files#diff-fb88962f9343ca7b8d31bfe34f5063136575e05eadae6fccb3b64658e14b0d6c
https://github.com/RustPython/RustPython/pull/8346/files#diff-fb88962f9343ca7b8d31bfe34f5063136575e05eadae6fccb3b64658e14b0d6c
https://github.com/RustPython/RustPython/pull/8346/files#diff-fb88962f9343ca7b8d31bfe34f5063136575e05eadae6fccb3b64658e14b0d6c
crates/vm/src/class.rshttps://github.com/RustPython/RustPython/pull/8346/files#diff-ea8866550ea2830f83d804b5bc2a03456c7eaa2308b786b0aa71a984ca25b8fe
View file https://github.com/bschoenmaeckers/RustPython/blob/8c53827626316aade37491a08f6c28cfc552c228/crates/vm/src/class.rs
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/RustPython/RustPython/pull/8346/{{ revealButtonHref }}
https://github.com/RustPython/RustPython/pull/8346/files#diff-ea8866550ea2830f83d804b5bc2a03456c7eaa2308b786b0aa71a984ca25b8fe
https://github.com/RustPython/RustPython/pull/8346/files#diff-ea8866550ea2830f83d804b5bc2a03456c7eaa2308b786b0aa71a984ca25b8fe
crates/vm/src/frame.rshttps://github.com/RustPython/RustPython/pull/8346/files#diff-03f2741d7d424014f3d2f0c82226be52fa58134aab34bf0780714ee67a248deb
View file https://github.com/bschoenmaeckers/RustPython/blob/8c53827626316aade37491a08f6c28cfc552c228/crates/vm/src/frame.rs
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/RustPython/RustPython/pull/8346/{{ revealButtonHref }}
https://github.com/RustPython/RustPython/pull/8346/files#diff-03f2741d7d424014f3d2f0c82226be52fa58134aab34bf0780714ee67a248deb
https://github.com/RustPython/RustPython/pull/8346/files#diff-03f2741d7d424014f3d2f0c82226be52fa58134aab34bf0780714ee67a248deb
crates/vm/src/types/slot.rshttps://github.com/RustPython/RustPython/pull/8346/files#diff-1b5587c15bdfe9ff552fbc35e014eef20d6b7934fbb31b922cf35d87e8837b7b
View file https://github.com/bschoenmaeckers/RustPython/blob/8c53827626316aade37491a08f6c28cfc552c228/crates/vm/src/types/slot.rs
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/RustPython/RustPython/pull/8346/{{ revealButtonHref }}
https://github.com/RustPython/RustPython/pull/8346/files#diff-1b5587c15bdfe9ff552fbc35e014eef20d6b7934fbb31b922cf35d87e8837b7b
https://github.com/RustPython/RustPython/pull/8346/files#diff-1b5587c15bdfe9ff552fbc35e014eef20d6b7934fbb31b922cf35d87e8837b7b
https://github.com/RustPython/RustPython/pull/8346/files#diff-1b5587c15bdfe9ff552fbc35e014eef20d6b7934fbb31b922cf35d87e8837b7b
https://github.com/RustPython/RustPython/pull/8346/files#diff-1b5587c15bdfe9ff552fbc35e014eef20d6b7934fbb31b922cf35d87e8837b7b
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.