Re: [C++-sig] Profiling object instantiation... a preliminary report
by David Abrahams other posts by this author
Mar 20 2002 5:10PM messages near this date
Re: [C++-sig] Profiling object instantiation... a preliminary report
|
Re: [C++-sig] Profiling object instantiation... a preliminary report
V2 wrapped objects are based on new-style classes. Python's new-style
classes do fill in the function table each time an attribute matching a
special function name is added, but the function placed in the table is
just a function which does the attribute lookup. Since there's no way to
generate an extern "C" linkage function with a template, I couldn't
actually fill these in with direct calls in most cases anyway. However,
the use of Python's new descriptor mechanism already cuts the number of
attribute lookups by a factor of 2.
By the way, Ralf's suggestion from many weeks ago that the best approach
is probably to avoid crossing the language boundary for each of these
unpicklings still sounds like the best way to speed the process up to
me.
-Dave
----- Original Message -----
From: "Ullrich Koethe" <koethe@[...].de>
To: <c++-sig@[...].org>
Sent: Wednesday, March 20, 2002 5:24 AM
Subject: Re: [C++-sig] Profiling object instantiation... a preliminary
report
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@[...].org Germany |
| koethe@[...].de |
| WWW: http://kogs-www.informatik.uni-hamburg.de/~koethe/ |
|________________________________________________________________|
_______________________________________________
C++-sig mailing list
C++-sig@[...].org
http://mail.python.org/mailman/listinfo/c++-sig
Thread:
Greg Landrum
David Abrahams
Ullrich Koethe
Ullrich Koethe
Martin Casado
Ralf W. Grosse-Kunstleve
Martin Casado
David Abrahams
David Abrahams
Ullrich Koethe
David Abrahams
David Abrahams
greg Landrum
|