How to do it...

As this is a PEP, there is no real code to create, unlike in previous chapters. What we will do is cover the details of the proposal and how they are intended to be implemented:

  1. Two new APIs would be added to the gc module:
    • The gc.set_mode(mode) API configures the garbage-collection mode between serial and threaded. If it is currently set to threaded, but the setting is switched to serial, the function waits for the garbage collection thread to complete before changing.
    • The gc.get_mode() API returns the current mode of operation.
  2. The collection mode can be switched between the two options, so it is recommended that it be set at the beginning of a program, or when child processes are created.
  3. The actual implementation happens ...

Get Secret Recipes of the Python Ninja now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.