Skip to content

Commit

Permalink
avoid the autological self-reference and provide more direct clarity …
Browse files Browse the repository at this point in the history
…to ShapeBase.delete() (#1104)

Co-authored-by: matanster <matanster>
  • Loading branch information
matanox committed May 10, 2024
1 parent 8a2e291 commit 823f220
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions pyglet/shapes.py
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

0 comments on commit 823f220

Please sign in to comment.