[C++-sig] Profiling object instantiation... a preliminary report

Ullrich Koethe koethe at informatik.uni-hamburg.de
Wed Mar 20 11:24:03 CET 2002


greg Landrum wrote:
> 
Hi,

> David has suggested that this is probably due to the attribute
> dictionary.  (Which immediately raises the question: if I were willing to
> live with objects with read-only attributes could I avoid this speed hit?).
> 

I don't know about the inner workings of CXX, but one possibility
immediately springs into mind: In BPL wrapped objects are like class
instances, and any access to a special function (such as "__getattr__"
or "__add__") involves at least one dictionary lookup. If, on the other
hand, CXX used normal Python objects, the special functions would be
stored in the appropriate slots of the objects' function tables (such as
tp_getattr, nb_add), and the lookup were much faster.

David, could BPL v2 arrange it so that special functions are accessed
via the function table rather than a dictionary lookup, if appropriate?
This would be good for speed as __getattr__ and arithmetic functions
tend to be used in inner loops.

Regards
Ulli

-- 
 ________________________________________________________________
|                                                                |
| Ullrich Koethe  Universität Hamburg  / University of Hamburg   |
|                 FB Informatik        / Dept. of Informatics    |
|                 AB Kognitive Systeme / Cognitive Systems Group |
|                                                                |
| Phone: +49 (0)40 42883-2573                Vogt-Koelln-Str. 30 |
| Fax:   +49 (0)40 42883-2572                D - 22527 Hamburg   |
| Email: u.koethe at computer.org               Germany             |
|        koethe at informatik.uni-hamburg.de                        |
| WWW:   http://kogs-www.informatik.uni-hamburg.de/~koethe/      |
|________________________________________________________________|




More information about the Cplusplus-sig mailing list