What's the public API alternative to _PyObject_GC_IS_TRACKED()?

Marco Sulla Marco.Sulla.Python at gmail.com
Wed Dec 29 03:29:06 EST 2021


On second thought, I think I'll do this for the pure py version. But I
will definitely not do this for the C extension, since it's anyway
strange that an immutable mapping inherits from a mutable one! I've
done it in the pure py version only for a matter of speed.

On Wed, 29 Dec 2021 at 09:24, Marco Sulla <Marco.Sulla.Python at gmail.com> wrote:
>
> On Wed, 29 Dec 2021 at 09:12, Dieter Maurer <dieter at handshake.de> wrote:
> >
> > Marco Sulla wrote at 2021-12-29 08:08 +0100:
> > >On Wed, 29 Dec 2021 at 00:03, Dieter Maurer <dieter at handshake.de> wrote:
> > >> Why do you not derive from `dict` and override its mutating methods
> > >> (to raise a type error after initialization is complete)?
> > >
> > >I've done this for the pure py version, for speed. But in this way,
> > >frozendict results to be a subclass of MutableMapping.
> >
> > `MutableMapping` is a so called abstract base class (--> `abc`).
> >
> > It uses the `__subclass_check__` (and `__instance_check__`) of
> > `abc.ABCMeta` to ensure `issubclass(dict, MutableMapping)`.
> > Those can be customized by overriding `MutableMapping.__subclasshook__`
> > to ensure that your `frozendict` class (and their subclasses)
> > are not considered subclasses of `MutableMapping`.
>
> Emh. Too hacky for me too, sorry :D


More information about the Python-list mailing list