Skip to content

Commit 6821291

Browse files
jzwinckjreback
authored andcommitted
ENH: use constant f32 eps, not np.finfo() during import
NumPy docs for np.finfo() say not to call it during import (at module scope). It's a relatively expensive call, and it modifies the GIL state. Now we just hard-code it, because it is always the value anyway. This avoids touching the GIL at import, which helps avoid deadlocks in practice. closes pandas-dev#14641 Author: John Zwinck <[email protected]> Closes pandas-dev#15691 from jzwinck/patch-1 and squashes the following commits: dadb97c [John Zwinck] DOC: mention pandas-dev#14641 in 0.20.0 whatsnew e565230 [John Zwinck] ENH: use constant f32 eps, not np.finfo() during import
1 parent 76e5185 commit 6821291

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

doc/source/whatsnew/v0.20.0.txt

+1
Original file line numberDiff line numberDiff line change
@@ -905,6 +905,7 @@ Bug Fixes
905905

906906

907907
- Bug in ``pd.read_csv()`` with ``float_precision='round_trip'`` which caused a segfault when a text entry is parsed (:issue:`15140`)
908+
- Avoid use of ``np.finfo()`` during ``import pandas`` removed to mitigate deadlock on Python GIL misuse (:issue:`14641`)
908909

909910
- Bug in ``DataFrame.to_stata()`` and ``StataWriter`` which produces incorrectly formatted files to be produced for some locales (:issue:`13856`)
910911
- Bug in ``pd.concat()`` in which concatting with an empty dataframe with ``join='inner'`` was being improperly handled (:issue:`15328`)

pandas/core/indexing.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1852,7 +1852,7 @@ def _convert_key(self, key, is_setter=False):
18521852

18531853

18541854
# 32-bit floating point machine epsilon
1855-
_eps = np.finfo('f4').eps
1855+
_eps = 1.1920929e-07
18561856

18571857

18581858
def length_of_indexer(indexer, target=None):

0 commit comments

Comments
 (0)