GH-41815: [Python] add use_threads option to feather.write_feather() #41820
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Rationale for this change
feather.write_feather
could implicitly invokeThreadPoolExecutor
when writing apandas.DataFrame
, making it unusable in anatexit
context. More details in #41815What changes are included in this PR?
Added a new default
True
parameteruse_threads
towrite_feather
. This name was selected to match that inread_feather
. Foruse_threads=True
,write_feather
passes annthreads=None
option toTable.from_pandas
, which will causepandas_compat.dataframe_to_array()
to heuristically determine whether to use threads or not. Foruse_threads=False
,nthreads=1
, which will result in serial behavior.Are these changes tested?
Yes,
test_use_threads
intest_feather.py
was expanded to ensure that serial and parallel writes produce the same file.Are there any user-facing changes?
Yes, new default parameter to user-facing
write_feather
.pyarrow.write_feather
can't be used inatexit
contexts to write apandas.DataFrame
#41815