Skip to content

Commit ef7dc2f

Browse files
gfyoungjreback
authored andcommitted
CLN: Cleanup code in parsers.pyx (#26386)
1 parent 7ba2ec8 commit ef7dc2f

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

pandas/_libs/parsers.pyx

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,14 @@ import pandas._libs.lib as lib
4141
from pandas._libs.khash cimport (
4242
khiter_t,
4343
kh_str_t, kh_init_str, kh_put_str, kh_exist_str,
44-
kh_get_str, kh_destroy_str, kh_resize_str,
44+
kh_get_str, kh_destroy_str,
4545
kh_float64_t, kh_get_float64, kh_destroy_float64,
4646
kh_put_float64, kh_init_float64, kh_resize_float64,
4747
kh_strbox_t, kh_put_strbox, kh_get_strbox, kh_init_strbox,
4848
kh_destroy_strbox,
4949
kh_str_starts_t, kh_put_str_starts_item, kh_init_str_starts,
5050
kh_get_str_starts_item, kh_destroy_str_starts, kh_resize_str_starts)
5151

52-
import pandas.compat as compat
5352
from pandas.core.dtypes.common import (
5453
is_categorical_dtype,
5554
is_integer_dtype, is_float_dtype,
@@ -477,14 +476,19 @@ cdef class TextReader:
477476

478477
self.verbose = verbose
479478
self.low_memory = low_memory
480-
self.parser.double_converter_nogil = xstrtod
481-
self.parser.double_converter_withgil = NULL
482-
if float_precision == 'high':
483-
self.parser.double_converter_nogil = precise_xstrtod
484-
self.parser.double_converter_withgil = NULL
485-
elif float_precision == 'round_trip': # avoid gh-15140
479+
480+
if float_precision == "round_trip":
481+
# see gh-15140
482+
#
483+
# Our current roundtrip implementation requires the GIL.
486484
self.parser.double_converter_nogil = NULL
487485
self.parser.double_converter_withgil = round_trip
486+
elif float_precision == "high":
487+
self.parser.double_converter_withgil = NULL
488+
self.parser.double_converter_nogil = precise_xstrtod
489+
else:
490+
self.parser.double_converter_withgil = NULL
491+
self.parser.double_converter_nogil = xstrtod
488492

489493
if isinstance(dtype, dict):
490494
dtype = {k: pandas_dtype(dtype[k])

0 commit comments

Comments
 (0)