[issue31356] Add context manager to temporarily disable GC

Nick Coghlan report at bugs.python.org
Wed Jan 31 22:55:53 EST 2018


Nick Coghlan <ncoghlan at gmail.com> added the comment:

A useful heuristic is that if something is named with CapWords, then class-like *usage* is explicitly supported (inheritance, isinstance checks, etc).

If it's named with snake_case or wordsruntogether, then calling it is OK, but you may run into quirky behaviour in class-style usage (e.g. it may not be a class at all in some implementations, or it may not be friendly to subclassing even when it is a full class).

So for something like this, snake_case is appropriate - you're meant to just use it, not subclass it. The fact that it's a type instance is an implementation detail.

(In other cases like contextlib.contextmanager we've made that implementation details status completely explicit in the code by having the public API be a wrapper function that returns an instance of a private class)

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue31356>
_______________________________________


More information about the Python-bugs-list mailing list