Commit 86cda43
committed
[pyroot] Fix and speed up the used-class scan in _find_used_classes
`_find_used_classes()` called `str()` on every variable of the target
namespace to detect class proxies by their string prefix. For a
namespace like `cppyy.gbl` that may also hold bound C++ *instances*
(e.g. `gInterpreter), `str()` of an instance triggers C++ overload
resolution for `operator<<`, which may attempt candidate implicit
conversions via JIT-compiled constructor calls. This is expensive and we
want to avoid it. More importantly, if the JIT compilation fails, it
results is unexpected hard-to-debug errors.
Skip bound instances entirely and only stringify actual types for the
class-proxy check. This is also a general speedup of pythonization
registration on all platforms.
The loop is restructured into mutually exclusive if/elif branches, one
per kind of value (class proxy, bound instance, template proxy).
Template proxies keep being recognized by their repr: they are not
Python types and cannot be reliably detected with isinstance, since
`cppyy.types.Template` is the backend proxy class, which the
`cppyy.Template` wrapper does not derive from.1 parent b6f8d4d commit 86cda43
1 file changed
Lines changed: 20 additions & 8 deletions
Lines changed: 20 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
272 | 272 | | |
273 | 273 | | |
274 | 274 | | |
| 275 | + | |
| 276 | + | |
275 | 277 | | |
276 | 278 | | |
277 | | - | |
278 | | - | |
279 | | - | |
280 | | - | |
281 | | - | |
282 | | - | |
283 | | - | |
284 | | - | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
285 | 297 | | |
286 | 298 | | |
287 | 299 | | |
| |||
0 commit comments