Skip to content

Commit ae96a23

Browse files
committed
add comment clarifying why the magic dunder is defined as part of methods (as opposed to through a special struct slot)
1 parent a6acbe6 commit ae96a23

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src_c/color.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,8 +259,17 @@ static PyMethodDef _color_methods[] = {
259259
{"premul_alpha", (PyCFunction)_premul_alpha, METH_NOARGS,
260260
DOC_COLOR_PREMULALPHA},
261261
{"update", (PyCFunction)_color_update, METH_FASTCALL, DOC_COLOR_UPDATE},
262+
263+
/**
264+
* While object.__bytes__(self) is listed in the Data Model reference (see:
265+
* https://docs.python.org/3/reference/datamodel.html#object.__bytes__) it
266+
* does not appear to have a PyTypeObject struct analog (see:
267+
* https://docs.python.org/3/c-api/typeobj.html), so we declare it for the
268+
* type as any other custom method.
269+
*/
262270
{"__bytes__", (PyCFunction)_color_bytes, METH_NOARGS,
263271
"Get a byte representation of the color"},
272+
264273
{NULL, NULL, 0, NULL}};
265274

266275
/**

0 commit comments

Comments
 (0)