Skip to content

Add a design topic page on lazy vs. eager implementations - #708

Merged
rgommers merged 3 commits into
data-apis:mainfrom
rgommers:lazy-impl-notes
Nov 27, 2023
Merged

Add a design topic page on lazy vs. eager implementations#708
rgommers merged 3 commits into
data-apis:mainfrom
rgommers:lazy-impl-notes

Conversation

@rgommers

Copy link
Copy Markdown
Member

Follow-up to gh-652, which added notes to the specifications for __bool__ & co on this topic.

@rgommersrgommers added Narrative Content Narrative documentation content. topic: Lazy/Graph Lazy and graph-based array implementations. labels Nov 16, 2023
@rgommersrgommers added this to the v2023 milestone Nov 16, 2023
@rgommers

Copy link
Copy Markdown
MemberAuthor

@seberg had one comment that is addressed in the second comment: point out that there is no built-in control flow beyond where (e.g., no cond) to avoid the __bool__.

Comment threadspec/draft/design_topics/lazy_eager.rst Outdated

@betatimbetatim left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good to me

@rgommers

Copy link
Copy Markdown
MemberAuthor

Three approvals and comments are addressed, so I'll go ahead and merge this. Thanks all!

@rgommers
rgommers merged commit 200d016 into data-apis:mainNov 27, 2023
@rgommers
rgommers deleted the lazy-impl-notes branch November 27, 2023 09:56
@betatim

Copy link
Copy Markdown
Member

On a more philosophical note: what should an array consuming library do to deal with these two variants of behaviour? There are two options that come to mind straight away: (1) state in your docs that of all Array API compliant array producing libraries you only support X, Y and Z (because they don't raise) or (2) add try excepts around your if statements?

Not sure if this PR is the best place to discuss this, but I started typing just before Ralf merged it, so will post here. Maybe an issue (with a follow up PR) is a better place?

@rgommers

Copy link
Copy Markdown
MemberAuthor

I think it's in practice a non-issue:

  • Few classes of algorithms should actually need __bool__; it's basically only iterative algorithms (e.g. minimizers, fitting routines)
  • For those that do need such iteration, they invariably already don't support lazy/graph algorithms - so I'd suggest simply documenting that fact in the relevant docstrings.

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

Labels

Narrative ContentNarrative documentation content.topic: Lazy/GraphLazy and graph-based array implementations.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@rgommers@betatim@seberg@leofang