bpo-36485: Add sys.clear_caches(). by serhiy-storchaka · Pull Request #12632 · python/cpython

Skip to content

Navigation Menu

Sign in

Appearance settings

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Appearance settings

Conversation

@serhiy-storchaka

Copy link Copy Markdown

Member

@serhiy-storchaka serhiy-storchaka commented

Mar 30, 2019

edited

Loading

It calls the __clearcache__() functions for every imported module
if it is defined.

https://bugs.python.org/issue36485

It calls the __clearcache__() functions for every imported module
if it is defined.

@ilevkivskyi

Copy link Copy Markdown

Member

I am not sure this is really needed, but FWIW I like this approach more than #12639

Comment thread

Python/sysmodule.c

/*[clinic end generated code: output=7bbac9db7bbef6c3 input=9e739bbc710495ff]*/
{
_Py_IDENTIFIER(__clearcache__);
PyObject *modules = PyMapping_Values(PyImport_GetModuleDict());
Copy link Copy Markdown

Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PyMapping_Values() should be checked for failure, no?

serhiy-storchaka reacted with thumbs up emoji

@github-actions

Copy link Copy Markdown

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions bot added the stale

Stale PR or inactive for long period of time.

label

Sep 21, 2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@gvanrossum gvanrossum Awaiting requested review from gvanrossum

@ilevkivskyi ilevkivskyi Awaiting requested review from ilevkivskyi

1 more reviewer

@ZackerySpytz ZackerySpytz ZackerySpytz left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

awaiting core review stale

Stale PR or inactive for long period of time.

type-feature

A feature request or enhancement

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

7 participants

@serhiy-storchaka @ilevkivskyi @ZackerySpytz @the-knights-who-say-ni @ezio-melotti @bedevere-bot @nazeerali4325-commits