Skip to content

Python: add bindings for AddCustomContext #1988

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

senyai
Copy link
Contributor

@senyai senyai commented May 20, 2025

I tested it.

@senyai senyai force-pushed the senyai-py-custom-context branch from afea827 to 9320f58 Compare May 20, 2025 17:15
@senyai senyai force-pushed the senyai-py-custom-context branch from 9320f58 to bd27591 Compare May 20, 2025 17:15
@@ -180,5 +180,9 @@ NB_MODULE(_benchmark, m) {
m.def("RunSpecifiedBenchmarks",
[]() { benchmark::RunSpecifiedBenchmarks(); });
m.def("ClearRegisteredBenchmarks", benchmark::ClearRegisteredBenchmarks);
m.def("AddCustomContext", benchmark::AddCustomContext, nb::arg("key"),
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not bind this directly as add_custom_context? That might also be IDE/completions-friendlier than the indirection by the above reassignment.

(I know you did it to match the rest of the examples, but in my opinion it's worth asking whether that convention should be kept.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I know of one subtle reason behind this. There's documentation for "AddCustomContext" and one can find it in __init__.py, which is easily accessible from IDE. Is it good enough reason? Maybe not. Maybe there should be good docstrings for every method. Currently, I'd give this issue low priority. For me, the lack of type annotations for most methods is much more important. And maybe the lack of format checking for (google_benchmark/benchmark.cc) in CI.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So, my answer is: convention should NOT be kept, and change of convention is not part of this issue.

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.

2 participants