Repository navigation
Start using Py_NewRef in a few modules - #3786
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughThis PR modernizes reference counting in four C extension modules by replacing manual ChangesReference Counting Modernization
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. 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. Review rate limit: 7/8 reviews remaining, refill in 7 minutes and 30 seconds.Comment |
When looking at ref counting #3783, I was surprised to see we don't use Py_NewRef at all throughout our codebase.
Docs: https://docs.python.org/3/c-api/refcounting.html#c.Py_NewRef
Instead of assigning something and then incref-ing it, we can use newref inline to return a new reference to the object. Which is the same thing, just more concise. I checked the generated assembly with my
add_global_arguments('/FAcsu', language: 'c')trick for MSVC, I did not see any meaningful change in the generated output.It seems that this is the preferred way of doing things in CPython internally now: python/cpython#99300