This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author scoder
Recipients Arfrever, Trundle, benjamin.peterson, daniel.urban, docs@python, eric.araujo, eric.snow, meador.inge, ncoghlan, pitrou, rhettinger, scoder, skrah
Date 2013-10-25.16:44:41
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <526A9FB6.5060503@behnel.de>
In-reply-to <CADiSq7e6BOV=jpteLD-bsDt+8TD340Lgda-CTjX_y7kyJt9ggA@mail.gmail.com>
Content
Nick Coghlan added the comment:
> Antoine Pitrou added the comment:
>> To be clear: the problem is with CPython calling the concrete APIs when
>> it shouldn't, rather than with the concrete APIs not behaving properly.
> 
> The boilerplate required to use them correctly renders them broken in my
> view

I think we disagree here. There is no boilerplate at all involved, as long
as its guaranteed that they are being called on the correct type of object.
User code may provide that guarantee either implicitly or explicitly, and
only the explicit way involves additional code (such as a type check). The
implicit way (that simply knows the exact type) would suffer from any code
additions to the fast paths in the specific C-API functions.

> particularly when they silently corrupt internal subclass state when
> misused instead of throwing an exception.

It has bothered me more than once that even the fast paths in those
functions usually contain type checks, which often means that the type
check is being executed twice: once as a special casing check before
calling the function and once as a safety check after entering it. As long
as the functions are being used correctly, the second check is just useless
code that unnecessarily takes time.

IMHO, it would be nice to have those internal type checks enabled *only*
for debug builds, although even then, there may be legitimate usages that
call these functions on subtypes (such as when called from within a well
defined subtype implementation, as you mentioned).
History
Date User Action Args
2013-10-25 16:44:42scodersetrecipients: + scoder, rhettinger, ncoghlan, pitrou, benjamin.peterson, eric.araujo, Arfrever, Trundle, skrah, meador.inge, daniel.urban, docs@python, eric.snow
2013-10-25 16:44:42scoderlinkissue10977 messages
2013-10-25 16:44:41scodercreate