README.md in pycall-1.2.1 vs README.md in pycall-1.3.0.dev

- old
+ new

@@ -59,9 +59,48 @@ math.sin(math.pi / 4) - Math.sin(Math::PI / 4) # => 0.0 Type conversions from Ruby to Python are automatically performed for numeric, boolean, string, arrays, and hashes. +### Releasing the RubyVM GVL during Python function calls + +You may want to release the RubyVM GVL when you call a Python function that takes very long runtime. +PyCall provides `PyCall.without_gvl` method for such purpose. When PyCall performs python function call, +PyCall checks the current context, and then it releases the RubyVM GVL when the current context is in a `PyCall.without_gvl`'s block. + +```ruby +PyCall.without_gvl do + # In this block, all Python function calls are performed without + # the GVL acquisition. + pyobj.long_running_function() +end + +# Outside of PyCall.without_gvl block, +# all Python function calls are performed with the GVL acquisition. +pyobj.long_running_function() +``` + +### Debugging python finder + +When you encounter `PyCall::PythonNotFound` error, you can investigate PyCall's python finder by setting `PYCALL_DEBUG_FIND_LIBPYTHON` environment variable to `1`. You can see the log like below: + +``` +$ PYCALL_DEBUG_FIND_LIBPYTHON=1 ruby -rpycall -ePyCall.builtins +DEBUG(find_libpython) find_libpython(nil) +DEBUG(find_libpython) investigate_python_config("python3") +DEBUG(find_libpython) libs: ["Python.framework/Versions/3.7/Python", "Python", "libpython3.7m", "libpython3.7", "libpython"] +DEBUG(find_libpython) libpaths: ["/opt/brew/opt/python/Frameworks/Python.framework/Versions/3.7/lib", "/opt/brew/opt/python/lib", "/opt/brew/opt/python/Frameworks", "/opt/brew/Cellar/python/3.7.2_1/Frameworks/Python.framework/Versions/3.7", "/opt/brew/Cellar/python/3.7.2_1/Frameworks/Python.framework/Versions/3.7/lib"] +DEBUG(find_libpython) Unable to find /opt/brew/opt/python/Frameworks/Python.framework/Versions/3.7/lib/Python.framework/Versions/3.7/Python +DEBUG(find_libpython) Unable to find /opt/brew/opt/python/Frameworks/Python.framework/Versions/3.7/lib/Python.framework/Versions/3.7/Python.dylib +DEBUG(find_libpython) Unable to find /opt/brew/opt/python/Frameworks/Python.framework/Versions/3.7/lib/darwin/Python.framework/Versions/3.7/Python +DEBUG(find_libpython) Unable to find /opt/brew/opt/python/Frameworks/Python.framework/Versions/3.7/lib/darwin/Python.framework/Versions/3.7/Python.dylib +DEBUG(find_libpython) Unable to find /opt/brew/opt/python/lib/Python.framework/Versions/3.7/Python +DEBUG(find_libpython) Unable to find /opt/brew/opt/python/lib/Python.framework/Versions/3.7/Python.dylib +DEBUG(find_libpython) Unable to find /opt/brew/opt/python/lib/darwin/Python.framework/Versions/3.7/Python +DEBUG(find_libpython) Unable to find /opt/brew/opt/python/lib/darwin/Python.framework/Versions/3.7/Python.dylib +DEBUG(find_libpython) dlopen("/opt/brew/opt/python/Frameworks/Python.framework/Versions/3.7/Python") = #<Fiddle::Handle:0x00007fc012048650> +``` + ## PyCall object system PyCall wraps pointers of Python objects in `PyCall::PyPtr` objects. `PyCall::PyPtr` class has two subclasses, `PyCall::PyTypePtr` and `PyCall::PyRubyPtr`. `PyCall::PyTypePtr` is specialized for type (and classobj