nodequeries vs python references

I’m a pretty experienced programmer, but i’m not too experienced with panda3d.

When i started building my game, i used the obvious approach (to me), and kept references to most things.

For instance, i have an object called “game” that i pass around to my actors. If i want to, say, access enemies from my player-object i would do so by writing something like:
self.game.enemies[x]

Recently, i’ve been thinking about doing actual queries when accessing objects instead, and scrapping some of the python references. They are all nodes, so it would not be a very big change code-wise.

What i wonder is:

  1. How would the change affect performance in the long run? It’s hard to tell right now, since the game is fairly simple at the moment.
  2. As this seems to map more closely to the overall panda3d architecture, would there be advantages, other than ones related to performance and readability?

Concerning the performance, I’ve been said that beside math, a frequent bottleneck are too many C++ calls. “Too many” surely means more than a few per frame, but still, that said, I’d guess you probably get a slight speed gain keeping your own references instead of traversing the scene graph each time a node is needed.

How about using the best of both?
I personally keep not a reference to each single object, but only to those I know I’ll use more frequently (I have those references in individual scenario classes), and on some classes I add a class attribute, which holds a node path, which points to the parent of a model group (e.g. scenery, cars etc.). The latter idea depends on your scene graph management.