On Oct 11, 2011, at 02:36 PM, Hrvoje Niksic wrote: >On 10/08/2011 04:54 PM, "Martin v. Löwis" wrote: >> tmp = PyObject_CallMethod(result, "update", "O", other); >> >> would be replaced with >> >> PyObject *tmp; >> Py_identifier(update); >> ... >> tmp = PyObject_CallMethodId(result,&PyId_update, "O", other); > >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 *s_update; // pick a naming convention > > PY_IDENTIFIER_INIT(update); > tmp = PyObject_CallMethodObj(result, s_update, "O", other); > > (but also PyObject_GetAttr(o, s_update), etc.) I like this better too because of the all-caps macro name. Something about seeing "Py_identifier" look like a function call and having it add the magical PyId_update local bugs me. It just looks wrong, whereas the all-caps is more of a cultural clue that something else is going on. -Barry
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4