Skip to content

Commit 16a44ad

Browse files
committed
Merge pull request #10199 from jreback/gil
PERF: releasing the GIL, #8882
2 parents d62f02b + 0bc2904 commit 16a44ad

File tree

10 files changed

+3053
-2619
lines changed

10 files changed

+3053
-2619
lines changed

doc/source/whatsnew/v0.17.0.txt

+25
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ users upgrade to this version.
1313

1414
Highlights include:
1515

16+
- Release the Global Interpreter Lock (GIL) on some cython operations, see :ref:`here <whatsnew_0170.gil>`
1617

1718
Check the :ref:`API Changes <whatsnew_0170.api>` and :ref:`deprecations <whatsnew_0170.deprecations>` before updating.
1819

@@ -58,8 +59,32 @@ Deprecations
5859
Removal of prior version deprecations/changes
5960
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6061

62+
.. _dask: https://dask.readthedocs.org/en/latest/
63+
64+
.. _whatsnew_0170.gil:
65+
66+
Releasing the GIL
67+
~~~~~~~~~~~~~~~~~
68+
69+
We are releasing the global-interpreter-lock (GIL) on some cython operations.
70+
This will allow other threads to run simultaneously during computation, potentially allowing performance improvements
71+
from multi-threading. Notably ``groupby`` and some indexing operations are a benefit from this. (:issue:`8882`)
72+
73+
For example the groupby expression in the following code will have the GIL released during the factorization step, e.g. ``df.groupby('key')``
74+
as well as the ``.sum()`` operation.
75+
76+
.. code-block:: python
77+
78+
N = 1e6
79+
df = DataFrame({'key' : np.random.randint(0,ngroups,size=N),
80+
'data' : np.random.randn(N) })
81+
df.groupby('key')['data'].sum()
82+
83+
Releasing of the GIL could benefit an application that uses threads for user interactions (e.g. ``QT``), or performaning multi-threaded computations. A nice example of a library that can handle these types of computation-in-parallel is the dask_ library.
84+
6185
.. _whatsnew_0170.performance:
6286

87+
6388
Performance Improvements
6489
~~~~~~~~~~~~~~~~~~~~~~~~
6590
- Added vbench benchmarks for alternative ExcelWriter engines and reading Excel files (:issue:`7171`)

pandas/core/common.py

-1
Original file line numberDiff line numberDiff line change
@@ -839,7 +839,6 @@ def take_nd(arr, indexer, axis=0, out=None, fill_value=np.nan,
839839

840840
func = _get_take_nd_function(arr.ndim, arr.dtype, out.dtype,
841841
axis=axis, mask_info=mask_info)
842-
843842
indexer = _ensure_int64(indexer)
844843
func(arr, indexer, out, fill_value)
845844

0 commit comments

Comments
 (0)