[Python-Dev] Identifier API (original) (raw)
Amaury Forgeot d'Arc amauryfa at gmail.com
Tue Oct 11 14:45:46 CEST 2011
- Previous message: [Python-Dev] Identifier API
- Next message: [Python-Dev] Identifier API
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
2011/10/11 Hrvoje Niksic <hrvoje.niksic at avl.com>
An alternative I am fond of is to to avoid introducing a new type, and simply initialize a PyObject * and register its address. For example:
PyObject *tmp; static PyObject *supdate; // pick a naming convention PYIDENTIFIERINIT(update); tmp = PyObjectCallMethodObj(result, supdate, "O", other); (but also PyObjectGetAttr(o, supdate), etc.) PYIDENTIFIERINIT(update) might expand to something like: if (!supdate) { supdate = PyUnicodeInternFromString("**update"); PyIdentifierAdd(&supdate); }
It should also check for errors; in this case the initialization is a bit more verbose: if (PY_IDENTIFIER_INIT(update) < 0) <return NULL or return -1 or goto error>;
-- Amaury Forgeot d'Arc -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20111011/a4062ce3/attachment.html>
- Previous message: [Python-Dev] Identifier API
- Next message: [Python-Dev] Identifier API
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]