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

[EXPERIMENTAL] Add "onchange" hook#262

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
eriknw wants to merge1 commit intopython-graphblas:main
base:main
Choose a base branch
Loading
fromeriknw:hooks

Conversation

eriknw
Copy link
Member

This is a PoC to see how invasive it is to add "onchange" hooks.

Theremay be two uses for this fromgraphblas-algorithms:

  1. Automatically invalidate the cache when the graph is modified.
    • This allows us to more safely expose the adjacency matrixA to the user.
  2. Make cached values read-only.

Overall, I'd say this isn't very invasive all things considered. The number of places hooks are in each file is:

  • expr.py:2
  • base.py:4
  • scalar.py:2
  • vector.py:3
  • matrix.py:3
  • _ss/matrix.py and _ss/vector.py: a bunch due to pack methods

This hook system is pretty simple for now. It only has one hook,"onchange", and it only passes the object that would be changed to the function. Other hooks and arguments to pass to the callbacks are possible (hence our use of**kwargs in the callback for future compatibility). This also doesn't try to manage having multiple callbacks, which is fine for our current use cases where the objects with hooks will be managed bygraphblas-algorithms.

We may want to add a simple API to manage hooks such as_add_hook,_has_hook,_call_hook, etc. to make it easier to evolve.

We can let this stew for a bit.

@eriknweriknw added featureSomething is missing lowpriority labelsJun 12, 2022
@eriknweriknw requested a review fromjim22kJune 12, 2022 15:53
@coveralls
Copy link

Coverage Status

Coverage increased (+0.01%) to 99.333% when pulling5e625ac on eriknw:hooks intoececafc on python-graphblas:main.

@eriknweriknw marked this pull request as draftOctober 19, 2022 16:32
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@jim22kjim22kAwaiting requested review from jim22k

Assignees
No one assigned
Labels
featureSomething is missinglowpriority
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@eriknw@coveralls

[8]ページ先頭

©2009-2025 Movatter.jp