Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Proposal] Lazy initialization of pygame module accelerate the startup. #1252

Open
1 task done
FAuditore opened this issue Dec 12, 2024 · 0 comments
Open
1 task done
Labels
enhancement New feature or request

Comments

@FAuditore
Copy link

Proposal

When I'm debugging on Windows PC, the pygame.init() often takes several seconds. Can this initialization be skipped when rendering is not required? e.g. only call the init() when render_mode=='human'

simple_env.py line 44

super().__init__()
if render_mode == "human":
    import pygame
    pygame.init()
    self.game_font = pygame.freetype.Font(
        os.path.join(os.path.dirname(__file__), "secrcode.ttf"), 24
    )
    self.width = ...
    self.height = ...
    ...

When I made this modification, the startup speed is much faster. Maybe there are other involved codes that need to be changed, but it looks good for me.

Motivation

Speed up the startup on windows

Pitch

No response

Alternatives

No response

Additional context

No response

Checklist

  • I have checked that there is no similar issue in the repo
@FAuditore FAuditore added the enhancement New feature or request label Dec 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant