Skip to content

Conversation

@markshannon
Copy link
Member

@markshannon markshannon commented Mar 18, 2025

Initial implementation of "code like" object support.

  • Adds methods to code object to implement the "code like" interface
  • Adds support for code-like objects in sys.monitoring

This is something to play with.
Obviously, this it will need more tests, especially for a C implemented code-like, and documentation.

@scoder @da-woods how does this look to you?

@da-woods
Copy link
Contributor

As you say in the issue: some of this is only worth doing when most of the monitoring tools also accept code objects. So I suspect we'd have to make Cython switchable between real and fake code objects for a while. But it looks reasonably straightforward.

@markshannon
Copy link
Member Author

A code object is "code like", so if Cython is already creating code objects, then it might as well continue to do so.

However, Cython created code objects are never going to be "proper" code objects, as they won't have bytecode, so I think trying to find an interface that is sufficient to support coverage, pdb, inspect, etc. and is implementable by Cython, Numba, Mypyc, etc. is worthwhile.

@markshannon
Copy link
Member Author

Elsewhere, we have seem to have settled on the approach of CPython understanding certain CodeObjects as artificial, probably Py_SIZE() == 0, so we won't need "code like" objects.

@markshannon markshannon closed this Oct 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants