[Python-ideas] Factory functions (was: RE: time.wallclock() or other similar stuff)

Guido van Rossum guido at python.org
Wed Nov 3 16:08:38 CET 2010

On Wed, Nov 3, 2010 at 1:58 AM, Antoine Pitrou <solipsis at pitrou.net> wrote:
> On Wed, 3 Nov 2010 13:26:27 +0800
> Kristján Valur Jónsson
> <kristjan at ccpgames.com> wrote:
>> And why are there factory functions in threading.py and not classes?
> I'm not sure, but it looks like a poor man's way of discouraging
> subclassing.

Indeed; the intention was that it should be possible to replace the
various lock classes with built-in objects without having to worry
about continuing subclasses. While this was done before built-in
objects could be subclassed, even today I still like to prevent
subclassing the lock classes since the ability to subclass still
constrains the implementation of the built-in type somewhat. I think
it's more important to have the possibility to switch in a faster
platform-specific lock implementation. I do admit that so far this
hasn't happened...

--Guido van Rossum (python.org/~guido)

More information about the Python-ideas mailing list