Skip to content
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

Array / AsyncArray design #2497

Open
d-v-b opened this issue Nov 17, 2024 · 0 comments
Open

Array / AsyncArray design #2497

d-v-b opened this issue Nov 17, 2024 · 0 comments

Comments

@d-v-b
Copy link
Contributor

d-v-b commented Nov 17, 2024

The Array and Group classes have methods that are synchronous, but many of these methods rely on async code. To solve this problem, the Array and Group classes have _async_array and _async_group attributes respectively. To use Array as an example, the Array._async_array attribute is an AsyncArray that actually does all of the IO, and so many Array methods just wrap a synchronized invocation of the corresponding AsyncArray invocation.

An alternative would be a single class with a mix of sync and async methods, where the sync form invokes the async form within a blocking function.

My question for this issue is whether we like our current design with two classes. Do people find it intuitive, etc?

I'm not arguing for changing anything, but I will note that I experience a mild distaste when I look up the implementation of an array method and find that it's actually just wrapping a method defined in a completely different class, which I must then look up to figure out what's really going on. The Array class has just 1 attribute, _async_array, which does all the work.

I'm not aware of a "synchronized layer above async layer" solution that doesn't involve extensive wrapping (if someone knows of one please share it!), but from a discoverability standpoint, Array._get_selection wrapping Array._a_get_selection seems a bit better than Array._get_selection wrapping AsyncArray._get_selection, especially if, in the first case, the sync and async methods are defined right next to each other in the source code.

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

No branches or pull requests

1 participant