Skip to content

[cppyy] fix: instantiation of templated functions #19450

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: master
Choose a base branch
from

Conversation

Vipul-Cariappa
Copy link
Contributor

When instantiating with another templated function

@Vipul-Cariappa
Copy link
Contributor Author

@siliataider, @vepadulano, You might be interested in this.
This enables what we were discussing yesterday.

@dpiparo
Copy link
Member

dpiparo commented Jul 23, 2025

Very nice. @Vipul-Cariappa would you mind perhaps adding a test?

Copy link

github-actions bot commented Jul 23, 2025

Test Results

    21 files      21 suites   3d 9h 30m 50s ⏱️
 3 218 tests  3 214 ✅ 0 💤 4 ❌
65 859 runs  65 855 ✅ 0 💤 4 ❌

For more details on these failures, see this check.

Results for commit db169ce.

♻️ This comment has been updated with latest results.

@Vipul-Cariappa Vipul-Cariappa force-pushed the fix/TemplateProxy-NonInit-ToStr branch from dfbe8ab to 8e00338 Compare July 24, 2025 06:58
@Vipul-Cariappa
Copy link
Contributor Author

Vipul-Cariappa commented Jul 24, 2025 via email

void baz(T a, U b, std::string c) { std::cout << "baz(" << a << "," << b << ",\"" << c << "\")\n"; }

template<typename F, typename... Args>
bool dataframe_define_mock(F callable, Args&&... args) {
Copy link
Member

Choose a reason for hiding this comment

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

I would give this function a more generic name, not to confuse it with a specific feature

Comment on lines 1357 to 1362
void foo() { std::cout << "foo!\n";}

void bar(int a, float b) { std::cout << "bar(" << a << "," << b << ")\n"; }

template <typename T, typename U>
void baz(T a, U b, std::string c) { std::cout << "baz(" << a << "," << b << ",\"" << c << "\")\n"; }
Copy link
Member

Choose a reason for hiding this comment

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

Since we've seen that in certain cases the function was called in a way that seemed correct but wasn't, I would actually return values from each of these functions, not using std::cout. The values can just be std::tuple of the input arguments returned as-is. The values should be checked on the Python side.

Copy link
Member

Choose a reason for hiding this comment

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

As discussed offline, since a std::tuple might incur in other issues, it's enough to return something like T with T being the integer passed as function argument.

@@ -142,6 +142,12 @@ PyObject* TemplateProxy::Instantiate(const std::string& fname,
} else
PyErr_Clear();

if (!bArgSet && Py_IS_TYPE(itemi, &TemplateProxy_Type)) {
Copy link
Member

Choose a reason for hiding this comment

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

I see the error

Py_IS_TYPE was not declared in this scope

On Alma8, maybe it's a missing macro from the Python version of that node?

@Vipul-Cariappa Vipul-Cariappa force-pushed the fix/TemplateProxy-NonInit-ToStr branch from 8e00338 to 6f6bf91 Compare July 25, 2025 07:33
when instantiating with another templated function
@Vipul-Cariappa Vipul-Cariappa force-pushed the fix/TemplateProxy-NonInit-ToStr branch from 6f6bf91 to db169ce Compare July 25, 2025 13:53
Copy link
Member

@vepadulano vepadulano left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

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.

4 participants