Skip to content

pyarrow: Cache the imported classes to avoid importing them each time#9439

Open
Tpt wants to merge 1 commit intoapache:mainfrom
Tpt:tpt/pyarrow-import
Open

pyarrow: Cache the imported classes to avoid importing them each time#9439
Tpt wants to merge 1 commit intoapache:mainfrom
Tpt:tpt/pyarrow-import

Conversation

@Tpt
Copy link

@Tpt Tpt commented Feb 19, 2026

Which issue does this PR close?

Rationale for this change

Speed up conversion by only importing pyarrow once.

What changes are included in this PR?

  • Use PyOnceLock::import to import the types.
  • Remove some not useful .extract::<PyBackedStr>()? (the Display implementation already does something similar)

Are these changes tested?

Covered by existing tests. It would be nice to add benchmark but it might require to:

  • either add a dependency to a python benchmark runner
  • write some hacky code to import pyarrow from criterion tests (likely by running pip/uv from the Rust benchmark code)

Are there any user-facing changes?

No

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python: avoid importing pyarrow classes ever time

1 participant