Import Question [SOLVED]

Right now, in my game, I have several custom classes. For the sake of my own organization preferences, I have each of these custom classes in it’s own file. As a result, some of the class files have repetitive imports, for example, two of them both import CollisionNode from pandac.PandaModules.

Do these repetitive imports put an unnecessary burden on the system? Meaning, would it create any difference in performance if I put the custom classes into a single file so that I was only doing the imports once?

No. This is just good design. The imported files are referencing the same memory, so there is no waste.

David

Excellent. Thank you, David.

For the record, if you import something, Python stores that loaded module in sys.modules - and that one is returned the next time you import the same thing.

If you really want to reload a module, you’d need to remove it from sys.modules before you import again.

or use reload