[Zodb-checkins] CVS: StandaloneZODB/ZODB - cPickleCache.c:1.33.68.2
Jeremy Hylton
jeremy@zope.com
Tue, 6 Nov 2001 12:32:15 -0500
Update of /cvs-repository/StandaloneZODB/ZODB
In directory cvs.zope.org:/tmp/cvs-serv22585
Modified Files:
Tag: jeremy-Standby-branch
cPickleCache.c
Log Message:
A few minor performance tweaks.
Also add a comment about the thin ice that gc_item() is treading on,
by calling PyDict_DelItem() while iterating over the same dict with
PyDict_Next().
In cases where PyDict_GetItem() returns NULL, check to see if there
was actually an error before clearing it. The PyErr_Clear() is
relatively expensive compared to PyErr_Occurred() and real errors are
probably impossible with the cache dict.
When calling self->setklassstate in invalidate(), do it efficiently by
inlining the argument tuple creation.
=== StandaloneZODB/ZODB/cPickleCache.c 1.33.68.1 => 1.33.68.2 ===
{
self->sum_deal++;
+ /* XXX The fact that this works will iterating over
+ self->data with PyDict_Next() is an accident of the
+ current Python dictionary implementation. */
return PyDict_DelItem(self->data, key);
}
@@ -399,15 +402,28 @@
}
else
{
- v=PyObject_CallFunction(self->setklassstate,
- "O", v);
+ PyObject *t = PyTuple_New(1);
+ if (t)
+ {
+ PyTuple_SET_ITEM(t, 0, v);
+ v = PyObject_Call(self->setklassstate, t, NULL);
+ Py_DECREF(t);
+ }
+ else
+ {
+ v = t;
+ }
if (v) Py_DECREF(v);
else PyErr_Clear();
}
else if (PyObject_DelAttr(v,py__p_changed) < 0)
PyErr_Clear();
}
- else PyErr_Clear();
+ else
+ {
+ if (PyErr_Occurred())
+ PyErr_Clear();
+ }
}
static PyObject *
@@ -461,15 +477,14 @@
{
PyObject *r, *key, *d=0;
- UNLESS (PyArg_ParseTuple(args,"O|O", &key, &d)) return NULL;
+ UNLESS (PyArg_ParseTuple(args, "O|O:get", &key, &d)) return NULL;
UNLESS (r=PyDict_GetItem(self->data, key))
{
if (d)
{
- PyErr_Clear(); /* Note that PyDict_GetItem() doesn't set an
- exception, but a comparison within it
- might. */
+ if (PyErr_Occurred())
+ PyErr_Clear();
r=d;
}
else