Interrogate/Interrogate_module outside dependencies

This question feels a bit awkward, like it’s simultaneously small enough to just be asked on the discord but at the same time I feel what I need to ask would make sense without a bit of background information attached, so here we go.

I’m using interrogate to generate c++ wrappers for a custom class that derives from ActorNode, which in turn derives from PhysicalNode.
When I initially compiled the pyd file and tried to test it I was met with this error:

file "", line 14, in <module>
     from gamecode.acrossGame.playerEntityBase import *
NameError: name 'PhysicalNode' is not defined

After a little research I discovered from here the -import command for Interrogate_module. After a little more expirementation, I discovered that if I use -import panda3d.physics everything works perfectly.

I do worry about this though, since this would probably import the entirety of panda3d.physics instead of the components that are actually utilized. I of course tried something like -import panda3d.physics.ActorNode but this got me a much more vague error.

does anyone happen to know of a cheaper way of dealing with this sort of problem?



EDIT: this might have something to do with the fact that interrogate’ s only generating an init/pyinit function for the library, and not the module. For now, I’ll treat that as a separate issue.
Double Edit: I forgot to mention that importing panda3d.core resolves the actornode dependency, but not the actornode’s own dependency of physicalnode.

After not working on this problem because of well… work, I’ve discovered the obvious: if I just import the dependencies before I import the custom class I don’t need to import the entirety of panda3d.physics.
like this:

from panda3d.physics import PhysicalNode
from <customClassLib> import *

it’s not clean, but it at the very least works.

Ah ha! I just realized that while it might be annoying to import those two dependencies every time I import my class, that doesn’t mean I have to every time I create a copy of said class!

I can just manually import the dependencies once in a python file where I declare a function that will set up and return a copy of my class, as well as doing a little behind the scenes work.

Then, I can just call the function from another file, requiring just a single import for the “manager” function.

There’s no difference in this regard between importing panda3d.physics and panda3d.physics.ActorNode; both will cause the entire panda3d.physics module to be loaded into memory, because it’s a single module and loading a module partially is not possible in Python. However, in no case will from <customClassLib> import * cause ActorNode to be added to the module namespace.

I didn’t know this! Thank you so much for telling me.
It’s probably a good thing that in exactly one month from now I’ll be taking a proper python course as opposed to teaching myself, so hopefully I won’t make quite as many mistakes such as this.