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

Antoine Pitrou solipsis at pitrou.net
Wed Nov 3 16:19:24 CET 2010

Le mercredi 03 novembre 2010 à 08:08 -0700, Guido van Rossum a écrit :
> 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...

Actually, it has (with both Lock and RLock); but I don't think
subclassing would have been an issue anyway.



More information about the Python-ideas mailing list