Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Design Document] First pass at async api options design#914

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
mpiannucci wants to merge3 commits intomain
base:main
Choose a base branch
Loading
fromdesign-docs/async-api

Conversation

mpiannucci
Copy link
Contributor

First pass at design for bringing async API back to python#620

This currently makes no decisions but starts to lay out options to iterate on.

@mpiannuccimpiannucci changed the titleFirst pass at async api options[Design Document] First pass at async api options designApr 15, 2025
@mpiannucci
Copy link
ContributorAuthor

Tagging@TomNicholas@kylebarron in case they have some insight or opinion!

Copy link
Collaborator

@parasebaparaseba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

This is great@mpiannucci . It very clearly explains the options.

I don't think anybody will like "Classes with Async methods", or I don't at least (but it's great to keep it in the doc as an option).

I feel the option with_async_repo and python doing the blocking is very compelling because of its simplicity and small code footprint. But, I'm concerned about having more async stuff in python, I have fought those async loops way more than I want to remember. For example, we would need to explore how well this interacts with multithreaded python code.

The everything-in-rust option is by far what takes more code, but also what feels safer. I'm afraid to ask, but ... how about writing a macro that can generate both versions of every method?

Co-authored-by: Sebastián Galkin <code@amisdelabc.com>
@mpiannucci
Copy link
ContributorAuthor

mpiannucci commentedApr 16, 2025
edited
Loading

But, I'm concerned about having more async stuff in python, I have fought those async loops way more than I want to remember. For example, we would need to explore how well this interacts with multithreaded python code.

This is my exact worry as well.

A macro actually might be the best way to do this, because the inner async closure will be the same for both sync and async and the only thing that changes are the call signatures and the runtime wrapper. I'll look into that

@paraseba
Copy link
Collaborator

the inner async closure will be the same for both sync and async and the only thing that changes are the call signatures and the runtime wrapper.

Exactly.

Maybe we can do a small proof of concept and see how it goes. The other concern with this is that we still need to create both python classes calling to the proper Rust object. I wonder if there are any tricks we play there without killing performance.

@kylebarron
Copy link
Contributor

kylebarron commentedApr 16, 2025
edited
Loading

I don't think anybody will like "Classes with Async methods", or I don't at least (but it's great to keep it in the doc as an option).

FWIW this is my preferred option 😄. E.g. in obstore the same operations are synchronous withdef get_range or async withasync def get_range_async.

I don't think there should be two separate classes that represent the same underlying concept and data on the rust side. E.g. for obstore the act of creating an S3Store is totally indifferent to whether you plan to use it synchronously or asynchronously. And the underlying Rust data (Arc<dyn ObjectStore>) is the same whether or not you use async methods on it. So I think it would be more confusing to have two separate classes that do the same thing.

Even when you might want an async constructor, I prefer having a single class. E.g. inkylebarron/arro3#313 I'm updating myParquetFile API. But since the underlying data held byParquetFile is the same in a sync or async case, I prefer having alternate constructors:open andopen_async (or potentially both__enter__ and__aenter__ to use as a sync or async context manager).

I also preferfetch_config_async instead ofasync_fetch_config in your example so you get quicker narrowing of autocompletion in IDE type hinting.

@paraseba
Copy link
Collaborator

Thanks@kylebarron . This gives me a new appreciation for that option.

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

@parasebaparasebaparaseba left review comments

@dcheriandcherianAwaiting requested review from dcherian

At least 1 approving review is required to merge this pull request.

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

3 participants
@mpiannucci@paraseba@kylebarron

[8]ページ先頭

©2009-2025 Movatter.jp