pythonarcade / arcade

Easy to use Python library for creating 2D arcade games.
http://arcade.academy
Other
1.71k stars 330 forks source link

Reconsider and evaluate top-level imports #2402

Open DigiDuncan opened 1 month ago

DigiDuncan commented 1 month ago

Leaving this here so we don't forget it. We need to take a quick lookover on what should be a top-level import, both for clarity, and to possibly reduce build size when arcade is imported.

pushfoo commented 1 month ago

I'm marking the evaluation of top-level imports as 3.0 mandatory since it's a commitment we have to keep to. Build size / packaging should be a separate issue.

einarf commented 1 month ago

I suspect input and media is adding a ~5 second startup time for me on my new laptop. Possibly also text. We have talked about this many times but I'm not sure if there is a clean solution. The rest of the imports I don't think cause any issues.

cspotcode commented 1 month ago

Some python libraries use tricks so that imports load on-demand, completely seamless from the consumer perspective. So if you never access a heavyweight component, it never imports.

pushfoo commented 1 month ago

Possibly also text. We have talked about this many times but I'm not sure if there is a clean solution.

I thought we stopped, but do we still load the Kenny fonts by default?

Some python libraries use tricks so that imports load on-demand, completely seamless from the consumer perspective. So if you never access a heavyweight component, it never imports.

Yep, that's pyglet. They also do some interesting things like having Window change per-platform.

einarf commented 4 weeks ago

I put this past 3.0 for now. It's high pri for later.

DigiDuncan commented 2 weeks ago

I think this should be in 3.0 mandatory, personally. Given that we're waiting on Pyglet 2.1 anyway, taking a day to do this while we can seems important. It can't reasonably be 3.0.x, since it'd be a breaking API change, so we'd have to wait until 3.1, and I'd rather not.