Skip to content

Instantly share code, notes, and snippets.

@markshannon
Last active November 1, 2023 16:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save markshannon/d7de345dcbd5499b8d00f8d6101830cd to your computer and use it in GitHub Desktop.
Save markshannon/d7de345dcbd5499b8d00f8d6101830cd to your computer and use it in GitHub Desktop.
example.c
op(_BINARY_OP_ADD_INT, (unused/1, left, right -- res)) {
if (IS_CONST(left) && IS_CONST(right)) {
res = MAKE_CONST(Py_NumberAdd(left->value, right->value));
emit(_LOAD_CONST_INLINE, res->value);
}
else {
res = UNKNOWN();
emit(_BINARY_OP_ADD_INT);
}
Py_DECREF(left);
Py_DECREF(right);
}
op(_GUARD_GLOBALS_VERSION, (version/1 --)) {
PyDictObject *dict = (PyDictObject *)GLOBALS();
PyDict_WatcherAdd(dict, ...);
/* Don't emit anything */
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment