On Wed, Sep 10, 2008 at 12:53 PM, Stefan Behnel <[EMAIL PROTECTED]> wrote:
> Lisandro Dalcin wrote:
>> On Wed, Sep 10, 2008 at 11:35 AM, Stefan Behnel <[EMAIL PROTECTED]>
>> wrote:
>>> This specific case is easy to handle as we can replace
>>> PyObject_GetAttrString() by the equivalent PyObject_GetAttr() call and
>>> create the Python string ourselves (which would normally happen inside
>>> of PyObject_GetAttrString).
>>
>> As a reminder, please use PyString_InternFromString() (or the py3k
>> equivalent).
>
> I considered doing that and rejected it as I do not see the gain in
> re-re-building the Python string instead of creating it once. Why do you
> think this is necessary?

Well, this is the way that PyObject_GetAttrString() is implemented. If
the call ends-up doing many dicts lookups (think about the chain
instance->class->[intermediate_class]->base_class), then using a
interned string is much faster (as string comparison ends-up being a
pointer comparison). In short, I believe this is a good optimization
if Cython wants its own version of PyObject_GetAttrString()
implemented in terms of PyObject_GetAttr().





>
> Stefan
>
> _______________________________________________
> Cython-dev mailing list
> [email protected]
> http://codespeak.net/mailman/listinfo/cython-dev
>



-- 
Lisandro Dalcín
---------------
Centro Internacional de Métodos Computacionales en Ingeniería (CIMEC)
Instituto de Desarrollo Tecnológico para la Industria Química (INTEC)
Consejo Nacional de Investigaciones Científicas y Técnicas (CONICET)
PTLC - Güemes 3450, (3000) Santa Fe, Argentina
Tel/Fax: +54-(0)342-451.1594
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to