Fix ArrayWrapper inlining to go to pyx only, not pxd#228
Conversation
- Add # wrap-hash: std directive to generate __hash__ from std::hash - Use cpp_hash alias to avoid conflict with Python's built-in hash() - Disable ArrayWrapper inlining for compatibility with projects that provide their own ArrayWrapper implementations (like OpenMS) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Re-enable ArrayWrapper inlining with the fix that adds ArrayWrappers to top_level_pyx_code instead of top_level_code. This ensures: - ArrayWrappers are only placed in .pyx files (not .pxd files) - No Cython declaration conflicts when projects have their own ArrayWrappers - Projects can now remove their own ArrayWrapper definitions and use autowrap's Benefits for projects using this: - Additional integer array types (Int8-64, UInt8-64) - Extra methods: __init__(size), resize(), size() - Better documentation 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
📝 WalkthroughWalkthroughThe PR relocates ArrayWrapper code generation from top-level code to pyx-specific top-level code in the CodeGenerator, reducing potential conflicts with pre-existing ArrayWrapper definitions. Minor documentation and formatting adjustments are also made. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
📜 Recent review detailsConfiguration used: Organization UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (8)
🔇 Additional comments (4)
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. Comment |
|
I guess if the tests pass it's fine. I am wondering if it is good to have in every pyx though. Might increase the compile times. I think that was the idea of having them in the Pxd to be shared across compiled modules. But I am also not understanding it completely. |
|
I'll merge it now but if you have time can you check if Claude has a better idea? |
Summary
This PR fixes ArrayWrapper inlining so that ArrayWrapper classes are placed only in
.pyxfiles, not.pxdfiles. This prevents Cython declaration conflicts when projects have their own ArrayWrapper definitions.Changes
top_level_pyx_codeinstead oftop_level_codewrite_pxd=True, this ensures ArrayWrappers only appear in pyx filesBenefits for downstream projects
Projects like OpenMS can now:
__init__(size),resize(),size()Testing
🤖 Generated with Claude Code
Summary by CodeRabbit
Bug Fixes
Documentation
✏️ Tip: You can customize this high-level summary in your review settings.