Macros | |
| #define | REPY_INLINE_COMPILE_CACHE_BLOCK(category, bytecode_identifier, code_mode, code_str) |
| Inside a function, construct a code block that compiles to bytecode a Python code string the first time it's run, storing the handle for that bytecode in a static variable. Allows setting a category name. | |
| #define | REPY_INLINE_COMPILE_CACHE(bytecode_identifier, code_mode, code_str) |
| Inside a function, construct a code block that compiles to bytecode a Python code string the first time it's run, storing the handle for that bytecode in a static variable. | |
Parsing a Python code string every time it needs to be executed would make for poor performance. The macros here will parse a Python code string the first time they are run, and provide a REPY_Handle to a Python bytecode object.
| #define REPY_INLINE_COMPILE_CACHE | ( | bytecode_identifier, | |
| code_mode, | |||
| code_str ) |
Inside a function, construct a code block that compiles to bytecode a Python code string the first time it's run, storing the handle for that bytecode in a static variable.
By only parsing and compiling the Python code string once, we can dramatically improve the performance of any function that needs to execute inline Python code.
This macro is identical to REPY_INLINE_COMPILE_CACHE_BLOCK, except it uses "REPY_INLINE_COMPILE_CACHE" as the category.
| bytecode_identifier | The name of the static variable that the bytecode handle will be assigned to. |
| code_mode | The type of code being compiled. See REPY_CodeMode for valid modes. |
| code_str | The Python code string to compile. Should be NULL-terminated. |
| #define REPY_INLINE_COMPILE_CACHE_BLOCK | ( | category, | |
| bytecode_identifier, | |||
| code_mode, | |||
| code_str ) |
Inside a function, construct a code block that compiles to bytecode a Python code string the first time it's run, storing the handle for that bytecode in a static variable. Allows setting a category name.
This macro forms the backbone of many of the other macros in this header, expecially those in the REPY_FN section. By only parsing and compiling the Python code string once, we can dramatically improve the performance of any function that needs to execute inline Python code.
The category argument becomes part of the resultant bytecode object's identifier string, which is displayed in Python error messages. In this header, macros that depend this one will use their own name for this argument. That way, if you get a error message from running inline Python code, you can see which macro caused the error along with the other source information.
| category | A category name used as part of the bytecode's identifying string. Many REPY macros that use this one will set this to their own macro names. |
| bytecode_identifier | The name of the static variable that the bytecode handle will be assigned to. |
| code_mode | The type of code being compiled. See REPY_CodeMode for valid modes. |
| code_str | The Python code string to compile. Should be NULL-terminated. |