Mango-Creators / pygess

Pygame Essentials. Provides for template classes to make pygame easier to use
https://pypi.org/project/pygess-py/
10 stars 1 forks source link

Lost performance in `physics.py` `update` method #20

Open Aareon opened 1 month ago

Aareon commented 1 month ago

The update method in physics.py is reimporting entities every time update is called, even though nothing should be changing to require an import each update. This will inevitably cause performance loss in a frequently used method.

CraftyRyte commented 1 month ago

Hey there. are you talking about this:

def update(self):
        from . import entity as ent

        self.entities = list(set(self.entities))
        for entity in self.entities:
            if isinstance(entity, (ent.Entity)):
                entity.update()

if thats the case, then im importing entity as to avoid a circular import from the entity class. thanks

Aareon commented 1 month ago

Perhaps you could modularize in such a way that you move the methods that both classes share so that you avoid the circular dependency and fix the error mentioned in this issue?

CraftyRyte commented 1 month ago

i'll try

zeusssz commented 1 month ago

alright, ill try and work on a rewrite of this. will get it out as soon as i can.