[Python-Dev] Identifier API (original) (raw)
Antoine Pitrou solipsis at pitrou.net
Tue Oct 11 16:24:30 CEST 2011
- Previous message: [Python-Dev] Identifier API
- Next message: [Python-Dev] Identifier API
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Tue, 11 Oct 2011 09:19:43 -0400 Barry Warsaw <barry at python.org> wrote:
On Oct 11, 2011, at 02:36 PM, Hrvoje Niksic wrote:
>On 10/08/2011 04:54 PM, "Martin v. Löwis" wrote: >> tmp = PyObjectCallMethod(result, "update", "O", other); >> >> would be replaced with >> >> PyObject *tmp; >> Pyidentifier(update); >> ... >> tmp = PyObjectCallMethodId(result,&PyIdupdate, "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 *supdate; // pick a naming convention > > PYIDENTIFIERINIT(update); > tmp = PyObjectCallMethodObj(result, supdate, "O", other); > > (but also PyObjectGetAttr(o, supdate), etc.) I like this better too because of the all-caps macro name. Something about seeing "Pyidentifier" look like a function call and having it add the magical PyIdupdate local bugs me. It just looks wrong, whereas the all-caps is more of a cultural clue that something else is going on.
+1 for something more recognizable. I think "const string" is more accurate than "identifier" as well.
Regards
Antoine.
- Previous message: [Python-Dev] Identifier API
- Next message: [Python-Dev] Identifier API
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]