Commit cfc5ab2
Try alternative names in REntry._GetPtr
Fixes the case of instantiating a C++ function template via
a Python TemplateProxy when a template argument passed by string (and
thus lazily evaluated) is of a type that has alternative names available
in the type system. Previously, only the user-provided type name was
tried to instantiate the function template `REntry::GetPtr` from the
RNTuple pythonization. Now, the pythonization first tries to instantiate
the function template via the user-provided string and, failing that, it
falls back to retrying the instantiation using all the available
alternative names for the name of the field type.
A new API in TClassTable is made available for this purpose. The list of
available alternative names for an input type name can now be queried
via `TClassTable::GetClassAlternativeNames`.
One advantage of this approach is that it does not require any change in
the RNTuple library and in cppyy. Also, it does not involve any change
in behaviour in core, the new API is completely detached from any
pre-existing code paths. One disadvantage is that in order to actually
trigger the right function template instantiation there needs to be some
manual work, currently done in the Pythonization of `REntry::GetPtr`. In
general, if a user were to write a C++ template function that needs to
take in a template argument type of the same kind of
AtlasLikeDataVector, they would need to try the first template
instantiation, see it failing, then retry again after querying the list
of alternative class names. This workflow is exemplified with a test.
Making this approach fully generic would require changes in cppyy which
on the surface look quite invasive. For example if a function has
multiple template arguments and all of them have multiple alternative
class names, one would probably need to trigger all the combinations of
template instantiations to look for the right one.
cherry-picked from f1fdd79 modulo the
changes made in roottest, which is not part of the root repository in
the v6-36-00-patches branch.1 parent 8308a3d commit cfc5ab2
File tree
3 files changed
+76
-2
lines changed- bindings/pyroot/pythonizations/python/ROOT/_pythonization
- core/cont
- inc
- src
3 files changed
+76
-2
lines changedLines changed: 34 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
18 | 51 | | |
19 | 52 | | |
20 | 53 | | |
21 | 54 | | |
22 | 55 | | |
23 | 56 | | |
24 | | - | |
| 57 | + | |
25 | 58 | | |
26 | 59 | | |
27 | 60 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| 28 | + | |
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
| |||
80 | 81 | | |
81 | 82 | | |
82 | 83 | | |
| 84 | + | |
83 | 85 | | |
84 | 86 | | |
85 | 87 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| 44 | + | |
44 | 45 | | |
45 | 46 | | |
46 | 47 | | |
| |||
258 | 259 | | |
259 | 260 | | |
260 | 261 | | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
261 | 268 | | |
262 | 269 | | |
263 | 270 | | |
| |||
270 | 277 | | |
271 | 278 | | |
272 | 279 | | |
273 | | - | |
| 280 | + | |
274 | 281 | | |
275 | 282 | | |
276 | 283 | | |
| |||
528 | 535 | | |
529 | 536 | | |
530 | 537 | | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
531 | 549 | | |
532 | 550 | | |
533 | 551 | | |
| |||
1030 | 1048 | | |
1031 | 1049 | | |
1032 | 1050 | | |
| 1051 | + | |
| 1052 | + | |
| 1053 | + | |
| 1054 | + | |
| 1055 | + | |
| 1056 | + | |
| 1057 | + | |
| 1058 | + | |
| 1059 | + | |
| 1060 | + | |
| 1061 | + | |
| 1062 | + | |
| 1063 | + | |
| 1064 | + | |
| 1065 | + | |
| 1066 | + | |
| 1067 | + | |
| 1068 | + | |
| 1069 | + | |
| 1070 | + | |
| 1071 | + | |
0 commit comments