2 hours ago · 5 min read1026 words · Tech · hide · 0 comments

Download a copy of CPython’s source: % git clone https://github.com/python/cpython Where is zip implemented? % cd cpython % grep -Irn "def zip" ... bunch of stuff about zipfile... % grep -Irn \"zip ... ./Python/bltinmodule.c:3313: "zip() argument %zd is shorter than argument%s%zd", ./Python/bltinmodule.c:3323: "zip() argument %zd is longer than argument%s%zd", ./Python/bltinmodule.c:3369:"zip(*iterables, strict=False)\n\ ./Python/bltinmodule.c:3385: "zip", /* tp_name */ ./Python/bltinmodule.c:3617: SETBUILTIN("zip", &PyZip_Type); ... Looks promising! This looks like a good start point — defining it along with the other builtins inside _PyBuiltin_Init in Python/bltinmodule.c: PyObject * _PyBuiltin_Init(PyInterpreterState *interp) { ... SETBUILTIN("zip", &PyZip_Type); where _PyBuiltin_Init gets called in Python/pylifecycle.c here: static PyStatus pycore_init_builtins(PyThreadState *tstate) { PyInterpreterState *interp = tstate->interp; PyObject *bimod = _PyBuiltin_Init(interp); where…

No comments yet. Log in to reply on the Fediverse. Comments will appear here.