Re: Better compatibility of the Python scientific/data stack with fast Python interpreters

Stefan Krah <[email protected]>
Newsgroups gmane.comp.python.numeric.general
Message-ID <[email protected]>
On Thu, May 15, 2025 at 03:41:52PM +0200, PIERRE AUGIER via NumPy-Discussion wrote:
> ========== PyPy HPy univ / CPy native (time ratio, smaller is better) ==========
> TestModule::test_noargs                       0.50
> TestModule::test_onearg_None                  0.60
> TestModule::test_onearg_int                   0.65
> TestModule::test_varargs                      0.93
> TestModule::test_call_with_tuple              2.21
> TestModule::test_call_with_tuple_and_dict     1.50
> TestModule::test_allocate_int                 0.67
> TestModule::test_allocate_tuple               6.33
> TestType::test_allocate_obj                   5.89
> TestType::test_method_lookup                  0.05
> TestType::test_noargs                         0.85
> TestType::test_onearg_None                    0.95
> TestType::test_onearg_int                     0.97
> TestType::test_varargs                        1.18
> TestType::test_len                            0.48
> TestType::test_getitem                        0.73
> TestHeapType::test_allocate_obj_and_survive   5.11
> TestHeapType::test_allocate_obj_and_die       4.07
> TestHeapType::test_method_lookup              0.05
> TestHeapType::test_noargs                     0.84
> TestHeapType::test_onearg_None                0.93
> TestHeapType::test_onearg_int                 0.96
> TestHeapType::test_varargs                    1.20
> TestHeapType::test_len                        0.50
> TestHeapType::test_getitem                    0.78
 
Thanks, that does look encouraging except for object creation times. I think hpy
could benefit from smaller benchmark examples. For example, I didn't find one
with PyNumberMethods except in numpy-hpy, which does some numpy-specific dark
magic.


This is the benchmark I tried to achieve but gave up after 30 min:

===================================================================================
#
# Fake should be an immutable object that uses tp_new but not tp_init and 
# has one nb_add number method. The method can cheat and just return a new
# Fake() without doing anything. The point of the benchmark is to test the
# speed of nb_add and object creation.
#

from fake import Fake

a = Fake()
b = Fake()

for _ in range(10000000):
    x = a + b
    y = b + x
    a = x
    b = y

print(y) # In case optimizing compilers have gotten smart and eliminate the loop.
===================================================================================


Stefan Krah



_______________________________________________
NumPy-Discussion mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/numpy-discussion.python.org/
Member address: [email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.