Am Donnerstag 04 Mai 2006 13:44 schrieb Kyo Guan:
> Hi guys:
>
>       I have a question about the this API.
>
> PyObject *
> PyString_InternFromString(const char *cp)
> {
>       PyObject *s = PyString_FromString(cp);
>       if (s == NULL)
>               return NULL;
>       PyString_InternInPlace(&s);
>       return s;
> }
>
>
> Why it always try to call PyString_FromString first?  if char* cp is
> already in the interned dict, this PyString_FromString call is waster. so I
> think this API should implement as:

Have you looked at the type of cp? It's const char*, that's not a Python type. 
PyString_FromString does nothing else than create a Python string-object from 
the C string, which can then in turn be interned. This call is necessary.

--- Heiko.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to