Skip to content

replacing the list implementation of window's event queue by a double ended queue#1362

Merged
benmoran56 merged 1 commit intopyglet:masterfrom
gergely-elias:window_event_queue_deque
Sep 25, 2025
Merged

replacing the list implementation of window's event queue by a double ended queue#1362
benmoran56 merged 1 commit intopyglet:masterfrom
gergely-elias:window_event_queue_deque

Conversation

@gergely-elias
Copy link
Copy Markdown
Contributor

I mentioned this a few days ago on discord, didn't get too much echo.
If there's any good reason to decline this PR, please feel free to do so.

In my case, this change does fix a frozen application. In case the event queue grows too large, list.pop(0) is very inefficient, leading to performance problems.
One can argue that the event queue growing too large is the result of a poor architecture on my side (I'm mixing a pyglet main window with a tkinter dialog, this happens when the tkinter dialog is open), and that the problem can be worked around (I currently do it with setting the pyglet window's visibility temporarily to False), or even properly solved (on discord I got detailed instructions about using a pyglet-based dialog window), so maybe this update is not needed. I can't see why it would hurt though.
But I don't know what other consequences the change can cause.

Thanks for taking this into consideration!

@benmoran56
Copy link
Copy Markdown
Member

Thanks for opening the PR. I think this is safe to merge. For typical pyglet apps/games where the event loop is not stalled, this event queue is unlikely to ever contain more than a few items. Still, even though the deque object technically could be slower (at tiny sizes) due to small built-in overhead, it seems immeasurable in my tests.

@benmoran56 benmoran56 merged commit cda0328 into pyglet:master Sep 25, 2025
16 checks passed
@gergely-elias gergely-elias deleted the window_event_queue_deque branch September 25, 2025 15:19
benmoran56 added a commit that referenced this pull request Oct 17, 2025
* Fix get_text_size for DirectWrite to include trailing whitespaces.

Fix get_text_size for DirectWrite to include trailing whitespaces, as it should get the length involving all characters.

* Add support for MacOSX to have transparent windows and overlays (#1339)

* Implement transparent framebuffer for MacOS.

* Make set_mouse_passthrough public, implement for win32.

* Update docs.

* Mispelling fix.

* Window improvements (#1345)

* Add get_monitor_name and get_display_id, implement on Mac OSX and Windows.

* Attempt xrandr implementation and use it if available.
Add missing depth attribute to the display.

* Fix a couple issues.

* Add custom get_default_screen methods for Xlib and Win32 to determine the primary screen.

* Implement OS specific get_default_screen for MacOSX.

* Adjust software cursor scale factor for MacOS for HiDPI. (#1343)

Co-authored-by: Benjamin <benmoran@protonmail.com>

* Font fixes (#1346)

* Fixes for text:
* Cache glyphs based on unique ID and indice to reduce cache collisions.
* Fix issue with inline elements crashing in a non-multiline scenario.

* * Add a test for single line inline element.

* pyglet.init: Simplify ENV option parsing and Options setter. (#1347)

* pyglet.init: Simplify ENV option parsing, and Options setter.

* Potential fix for code scanning alert no. 1821: Use of a print statement at module level

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>

* pyglet.options: restore code to automatically disable debug_gl when optimized or frozen

---------

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>

* math: minor performance improvements to matrix multiplication

* math: simplify matmul operations for small speedup.

* Ready v2.1.8 release.

* Fix attribute pointer issue for integers. (#1351)

* Add missing abstract methods to HeadlessScreen (#1350)

* Improve missing or underdeveloped math doc (#1295)

* Improve missing or underdeveloped math doc

* Add missing quaternion docstrings

* Expand stub docstrings for Quaternions

* Add new docstrings for undocumented methods in Quaternion

* Add some cross-refs

* Update math.py

* Update math.py

* Update math.py

* Update math.py

---------

Co-authored-by: Benjamin <benmoran@protonmail.com>

* input.linux: implement poll method on EvdevDevice

* Add Controller dpad, leftanalog, rightanalog attributes for polling purposes.

* input.linux: Add support for the evdev SYN_DROPPED event.

* input.linux: Add support for the evdev SYN_DROPPED event.

* Minor cleanups

* Linting & typing fixes.
Reuse buffer when possible.

* Ready v2.1.9

* fix typing of Label.__init__'s align argument (#1361)

* replacing the list implementation of window's event queue by a double ended queue (#1362)

* input.evdev: Remove debug print

* input.evdev: Do not attempt to reuse Controller instances on re-connect. Naming conflict can occur.

* Add support for FFmpeg 8.0 (#1365)

* Update CI matrix Python versions (add 3.13 and 3.14, remove 3.8) (#1366)

* Enable Python 3.13 and 3.14 in CI matrix

* Remove Python 3.8 from CI matrix

* Fixed number of elements for GL_FLOAT_MAT3 (9, not 6) in pyglet.graphics.shader._uniform_setters (#1364)

* Fix up regressions after merge from master

* Fix up regressions after merge from master

---------

Co-authored-by: caffeinepills <vhxonline@gmail.com>
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Co-authored-by: Paul <36696816+pushfoo@users.noreply.github.com>
Co-authored-by: Gergely Elias <gergely.elias@gmail.com>
Co-authored-by: Sylvain Demongeot <sdem2011@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants