I noticed you're using pygame only for the image reading but also importing PIL
You can slightly optimize things if you change the render function to this
ive timed the 2 modules and the read time is exactly the same. (i think pygame uses PIL to read anyways? but dont quote me on that)
it avoids the 2 flips and since you're not using pygame anywhere else you can remove it as a dependancy
i tried converting to a numpy array instead of .tobytes but was slightly slower so no luck there
You can slightly optimize things if you change the render function to this
Code:
def reload(self):
self.reset()
image = Image.open(self.path)
self.width,self.height = image.size[:2]
image = image.tobytes('raw', 'RGBA')
self.data = image
it avoids the 2 flips and since you're not using pygame anywhere else you can remove it as a dependancy
i tried converting to a numpy array instead of .tobytes but was slightly slower so no luck there
Last edited: