sumerc / yappi

Yet Another Python Profiler, but this time multithreading, asyncio and gevent aware.
MIT License
1.44k stars 72 forks source link

Are numpy, opencv, scipy, pandas, etc which are wrappers for compilied implementations "builtins"? #76

Closed drjasonharrison closed 3 years ago

drjasonharrison commented 3 years ago

Wondering when a function is treated as a "builtin". Are numpy, opencv, scipy, pandas, etc which are wrappers for compilied implementations "builtins"?

There is a note to run a manual test using scipy/numpy, but I cannot find a tests script or further details: https://github.com/sumerc/yappi/blob/master/tests/manual_tests.txt

This test uses "yappi.start(builtins=True)" when using testing "old style co-routines" with asyncio, but not for all asyncio tests: https://github.com/sumerc/yappi/blob/master/tests/test_asyncio.py

sumerc commented 3 years ago

A builtin function means any function that is implemented in C API. Any standard library function that is implemented on a C extension (for example: time.sleep is implemented in a C module) or any 3rd party C extension function.

So, coming to your original question: I assume there are lots of builtin functions in these libraries(numpy, scipy, pandas) as there are lots of code implemented in C.

Just for reference, for more information on what functions are builtins, this is where it is defined in CPython: (PYCfunctionObject struct) https://github.com/python/cpython/blob/0ab152c6b5d95caa2dc1a30fa96e10258b5f188e/Objects/methodobject.c#L44

sumerc commented 3 years ago

Assuming the answer make sense for you! Closing the issue for now, pls do not hesitate to re-open if there is still any unclear points.