You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Correctly maintaining the gabarge collection mechanisms of the two languages causes benchmarking issues, which can be observed when using Python's timeit.
# juliausing TyPython
using TyPython.CPython
@export_pyfunctionadd(a::Int, b::Int)::Intreturn a + b
end@export_pymodule myops begin
add =Pyfunc(add)
end# pythonimport operators
%timeit myops.add(1, 2) # 500ns%timeit operator.add(1, 2) # 49ns
Above benchmark for Python operator.add is fine, but quite unfair for the Julia one, as in the realworld cases, myops.add works much faster:
This is because Julia uses a real GC which will scan the heap instead of Python's reference counting. Calling into a small function from a foreign language (like CPython) can trigger a long GC operation.
Besides, WITH_GIL is so far a bit slow as it calls is_calling_julia_from_python. Such process is required when finalizing a Julia wrapped Python object.
Correctly maintaining the gabarge collection mechanisms of the two languages causes benchmarking issues, which can be observed when using Python's
timeit
.Above benchmark for Python
operator.add
is fine, but quite unfair for the Julia one, as in the realworld cases,myops.add
works much faster:This is because Julia uses a real GC which will scan the heap instead of Python's reference counting. Calling into a small function from a foreign language (like CPython) can trigger a long GC operation.
Besides,
WITH_GIL
is so far a bit slow as it callsis_calling_julia_from_python
. Such process is required when finalizing a Julia wrapped Python object.jnumpy/TyPython/src/CPython.APIs.jl
Lines 13 to 17 in d132c71
jnumpy/TyPython/src/CPython.APIs.jl
Lines 193 to 196 in d132c71
The text was updated successfully, but these errors were encountered: