Skip to content

CLN: Cleanup code in parsers.pyx #26386

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 14, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions pandas/_libs/parsers.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,14 @@ import pandas._libs.lib as lib
from pandas._libs.khash cimport (
khiter_t,
kh_str_t, kh_init_str, kh_put_str, kh_exist_str,
kh_get_str, kh_destroy_str, kh_resize_str,
kh_get_str, kh_destroy_str,
kh_float64_t, kh_get_float64, kh_destroy_float64,
kh_put_float64, kh_init_float64, kh_resize_float64,
kh_strbox_t, kh_put_strbox, kh_get_strbox, kh_init_strbox,
kh_destroy_strbox,
kh_str_starts_t, kh_put_str_starts_item, kh_init_str_starts,
kh_get_str_starts_item, kh_destroy_str_starts, kh_resize_str_starts)

import pandas.compat as compat
from pandas.core.dtypes.common import (
is_categorical_dtype,
is_integer_dtype, is_float_dtype,
Expand Down Expand Up @@ -477,14 +476,19 @@ cdef class TextReader:

self.verbose = verbose
self.low_memory = low_memory
self.parser.double_converter_nogil = xstrtod
self.parser.double_converter_withgil = NULL
if float_precision == 'high':
self.parser.double_converter_nogil = precise_xstrtod
self.parser.double_converter_withgil = NULL
elif float_precision == 'round_trip': # avoid gh-15140

if float_precision == "round_trip":
# see gh-15140
#
# Our current roundtrip implementation requires the GIL.
self.parser.double_converter_nogil = NULL
self.parser.double_converter_withgil = round_trip
elif float_precision == "high":
self.parser.double_converter_withgil = NULL
self.parser.double_converter_nogil = precise_xstrtod
else:
self.parser.double_converter_withgil = NULL
self.parser.double_converter_nogil = xstrtod

if isinstance(dtype, dict):
dtype = {k: pandas_dtype(dtype[k])
Expand Down