Friday, 15 September 2023

How to create a code object in python?

I'd like to create a new code object with the function types.CodeType() .
There is almost no documentation about this and the existing one says "not for faint of heart"
Tell me what i need and give me some information about each argument passed to types.CodeType ,
possibly posting an example.

Note:
In normal use cases you will just need the builtin function compile()
You should use types.CodeType() only if you want to create new instructions that couldn't be obtained writing normal source code and that require direct access to bytecode.



from How to create a code object in python?

No comments:

Post a Comment