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

Refactor declarative function and make call_func kwargs optional #569

Closed
wants to merge 1 commit into from

Conversation

frmdstryr
Copy link
Contributor

@frmdstryr frmdstryr commented Jan 20, 2025

This refactors declarative_function's Invoke to:

  • use vectorcalls
  • cache the strings used
  • Avoid creating empty f_locals dict
  • Avoid creating empty kwargs dict

It also slightly modifies call_func:

  • require 4 arguments because I can't find any uses with 3 arguments
  • allow func_kwargs to be null or None (see below).

Since all standard handlers create an empty dict and pass it to kwargs that just gets checked for a dict then ignored because it is empty. Likewise previously every dfunc call that has no kwargs was internally creating a dict just to do nothing with it in call_func. With this change the DFunc__call__'s PyObject* kwargs can be passed to call_func untouched (and if null does nothing).

Copy link

codecov bot commented Jan 20, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 70.91%. Comparing base (1f13f6a) to head (9be053c).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #569   +/-   ##
=======================================
  Coverage   70.91%   70.91%           
=======================================
  Files         287      287           
  Lines       25698    25698           
  Branches     3641     3641           
=======================================
  Hits        18224    18224           
  Misses       6385     6385           
  Partials     1089     1089           

@frmdstryr
Copy link
Contributor Author

After profiling this has practically no impact so forget it.

@frmdstryr frmdstryr closed this Jan 24, 2025
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

Successfully merging this pull request may close these issues.

1 participant