Re: [Sqlalchemy-tickets] [sqlalchemy] #2720: new C extensions for attribute accessing
Brought to you by:
zzzeek
|
From: sqlalchemy <mi...@zz...> - 2013-05-08 01:09:57
|
#2720: new C extensions for attribute accessing
-----------------------------------+---------------------------------------
Reporter: zzzeek | Owner: zzzeek
Type: enhancement | Status: new
Priority: medium | Milestone: 0.9.0
Component: cextensions | Severity: very major - up to 2 days
Resolution: | Keywords:
Progress State: not decided upon |
-----------------------------------+---------------------------------------
Comment (by zzzeek):
OK...can you tell me about this:
{{{
basic_dict = PyObject_GetAttrString(instance, "__dict__");
142 if (basic_dict == NULL) {
143 /* No problem, we'll fall back to the generic
implementation anyway */
144 PyErr_Clear();
145 }
}}}
what it seems like we're doing here, is seeing if `__dict__` is there, and
if so, then great we can skip using `instance_dict()`. That's not
actually how `instance_dict()` is supposed to work - it's supposed to be
consulted unconditionally. The whole `instance_dict()` thing is really
unfortunate in that I think there is exactly one application on the planet
that actually needs it to access something other than `__dict__`, but the
fact is that in the default case it is actually an `attrgetter` for
`__dict__` and should be extremely fast. Am I correct about that step
and can that be removed, hopefully simplifying the code ? Overall it's
a little weird that we're replacing literally six lines of Python code
with 426 lines of C.
--
Ticket URL: <http://www.sqlalchemy.org/trac/ticket/2720#comment:12>
sqlalchemy <http://www.sqlalchemy.org/>
The Database Toolkit for Python
|