Skip to content

Reconsider and evaluate top-level imports #2402

Closed

Description

@DigiDuncan

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.

Activity

  1. added this to the 3.0 mandatory milestone on Oct 9, 2024
  2. pushfoo commented on Oct 9, 2024

    @pushfoo
    Member

    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.

  3. einarf commented on Oct 10, 2024

    @einarf
    Member

    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.

  4. cspotcode commented on Oct 10, 2024

    @cspotcode
    Collaborator

    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.

  5. pushfoo commented on Oct 10, 2024

    @pushfoo
    Member

    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.

  6. modified the milestones: 3.0 mandatory, 3.0.x on Oct 23, 2024
  7. einarf commented on Oct 25, 2024

    @einarf
    Member

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

  8. DigiDuncan commented on Nov 4, 2024

    @DigiDuncan
    CollaboratorAuthor

    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.

  9. modified the milestones: 3.0.x, 3.1 on Feb 2, 2025
  10. einarf commented on Feb 2, 2025

    @einarf
    Member

    Import time on windows with my current project(s)

    • Initial run when OS have flushed caches: 5.82s
    • Next runs: 1.75s

    We can probably get this down below a second with lazy imports but it will still be a problem for projects with text and controller input.

  11. modified the milestones: 3.1, Future on Mar 29, 2025
  12. pvcraven commented on Oct 9, 2026

    @pvcraven
    Member

    Closing this. Both parts are done for 4.0:

    Import time (#2964): import arcade went from about 2.7 to 0.9 seconds on Windows.

    • Most of the time was pyglet listing input devices when pyglet.input is imported. Arcade's controller functions now import it on first use.
    • Sound still loads at import on purpose, so playing the first sound never makes a game stutter.

    Top-level names (#2965): we went through all 169 names in arcade.__all__ and removed the ones that were outdated, duplicated or wrong:

    • AnimatedWalkingSprite (already documented as deprecated) and the FACE_* constants only it used
    • get_game_controllers(), a duplicate of get_joysticks() whose name suggested it returned game controllers
    • the duplicate draw_lrbt_rectangle_filled / draw_lrbt_rectangle_outline entries in __all__

    We kept some on purpose:

    • set_background_color and MOUSE_BUTTON_*. They overlap newer APIs, but they're beginner-friendly and used in examples and docs.
    • start_render/finish_render and the timing functions, which are still current.
    • Advanced classes such as ArcadeContext and DefaultTextureAtlas, which are documented and used.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions