Skip to content

Instantly share code, notes, and snippets.

View erlend-aasland's full-sized avatar

Erlend E. Aasland erlend-aasland

View GitHub Profile
@erlend-aasland
erlend-aasland / CMakeLists.txt
Created June 6, 2022 11:33
python/cpython#93421: simulate DB API rowcount attribute
cmake_minimum_required(VERSION 3.14)
project(
TestSQLite
VERSION 0.1.0
LANGUAGES C
)
find_package(SQLite3 REQUIRED)
cmake_minimum_required(VERSION 3.14)
project(
TestSQLite
VERSION 0.1.0
LANGUAGES C
)
find_package(SQLite3 REQUIRED)
@erlend-aasland
erlend-aasland / gist:a7ca3cff95b136e272ff5b03447aff21
Created February 10, 2022 09:27
CPython macros that reuse args
/*
* List of macros that reuse their arguments. All macros have been squashed to single line macros.
* The list was built some time autumn 2021.
*/
#define COMMON_FIELDS(PREFIX) PyObject *PREFIX ## globals; PyObject *PREFIX ## builtins; PyObject *PREFIX ## name; PyObject *PREFIX ## qualname; PyObject *PREFIX ## code;
#define GENERATE_ASDL_SEQ_CONSTRUCTOR(NAME, TYPE) asdl_ ## NAME ## _seq *_Py_asdl_ ## NAME ## _seq_new(Py_ssize_t size, PyArena *arena) { asdl_ ## NAME ## _seq *seq = NULL; size_t n; if (n > SIZE_MAX - sizeof(asdl_ ## NAME ## _seq)) { PyErr_NoMemory(); return NULL; } n += sizeof(asdl_ ## NAME ## _seq); seq = (asdl_ ## NAME ## _seq *)PyArena_Malloc(arena, n); if (!seq) { PyErr_NoMemory(); return NULL; } memset(seq, 0, n); seq->size = size; seq->elements = (void**)seq->typed_elements; return seq; }
#define ISWHITESPACE(x) ((x) == ENDMARKER || (x) == NEWLINE || (x) == INDENT || (x) == DEDENT)
#define PyAnySet_Check(ob) (Py_IS_TYPE(ob, &PySet_Type) || Py_IS_TYPE(ob, &PyFrozenSet_Type) || PyType_