[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[pygame] pygame and file object compatibility; slow.



Currently I am working on a game project in pygame. We have a library
folder containing all of our images, text files, and fonts. We are
converting this to an archive file because we have many many files
(~12,000) and don't want to litter folders and files everywhere on a
users computer. We turned to the tarfile module simply because it was
built in and easy to use. Currently, I am using tarfile's extractfile
to retrieve a file object from the tar file and put it into memory.
Pygame does not like tarfile's file objects at all.

Using pygame.image.load, if I pass the filename and directory, the
load time is near instant at 0.0 ~ 0.0009s. Whereas passing the file
object created by tarfile increases the load time to an insane 1.4 -
1.5s! Even worse: passing a file object to pygame.font.Font produces a
segmentation fault. Am I missing something or is there an issue with
tar file objects?

I have a feeling this will be consistent with many different file
objects. Any help is greatly appreciated and welcomed.