Skip to content

REF: route object-dtype parser fallbacks through _string_convert#65933

Open
jbrockmendel wants to merge 2 commits into
pandas-dev:mainfrom
jbrockmendel:perf-strings-2
Open

REF: route object-dtype parser fallbacks through _string_convert#65933
jbrockmendel wants to merge 2 commits into
pandas-dev:mainfrom
jbrockmendel:perf-strings-2

Conversation

@jbrockmendel

Copy link
Copy Markdown
Member

In TextReader._convert_tokens, the object-dtype fallbacks went through _convert_with_dtype(np.dtype("object"), ...), whose object branch just delegates to _string_convert (the na_fset / user_dtype / raise_on_invalid args are ignored there). This calls _string_convert directly instead, and breaks out of the cast-order loop early once dt reaches object (the last entry), skipping the _convert_with_dtype dispatch chain.

Behavior-neutral cleanup that removes a layer of indirection. It's a prelim split off from GH-65283 (read_csv emitting pyarrow-backed string arrays from the C parser), where these call sites grow an allow_pyarrow argument — landing the neutral refactor separately keeps that PR focused on the new fast path.

  • Full pandas/tests/io/parser/ suite passes (4480 passed, 174 skipped, 192 xfailed)
  • pre-commit run clean

🤖 Generated with Claude Code

In TextReader._convert_tokens, the object-dtype fallbacks went through
_convert_with_dtype(np.dtype("object"), ...), which simply delegates to
_string_convert (ignoring na_fset / user_dtype / raise_on_invalid). Call
_string_convert directly instead, and break out of the cast loop early
when the cast order reaches object. Behavior-neutral; removes a layer of
indirection ahead of GH#65283.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@jbrockmendel jbrockmendel added Refactor Internal refactoring of code IO CSV read_csv, to_csv labels Jun 21, 2026
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

IO CSV read_csv, to_csv Refactor Internal refactoring of code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant