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

ShapeBase.delete scenarios clarification #1104

Merged
merged 1 commit into from
May 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 8 additions & 6 deletions pyglet/shapes.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,12 +395,14 @@ def draw(self) -> None:
def delete(self) -> None:
"""Force immediate removal of the shape from video memory.

You should usually call this whenever you delete a shape. Unless
you are using manual garbage collection, Python might not call
the finalizer as soon as the sprite falls out of scope.

Manual garbage collection is a very advanced technique. See
Python's :py:mod:`gc` module documentation to learn more.
You should usually call this whenever you no longer need the shape.
Otherwise, Python may call the finalizer of the shape instance only
some time after the shape has fallen out of scope, and the shape's video
memory will not be freed until the finalizer is eventually called by
garbage collection.

Implementing manual garbage collection may satisfy the same concern
without using the current method, but is a very advanced technique.
"""
if self._vertex_list is not None:
self._vertex_list.delete()
Expand Down