<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
</head>
<body bgcolor="#ffffff" text="#000000">
<br>
<br>
There are a bunch of type-checking macros in Include/*.h.  Most classes
only provide one, Check(), implemented as follows:<br>
<blockquote>#define PyWhatever_Check(ob) (Py_TYPE(ob) ==
&PyWhatever_Type)<br>
</blockquote>
Examples of this style include PyRange, PyMemoryView, PyFunction, and
PySlice.<br>
<br>
Then there are types with a more sophisticated view of type identity. 
For example, an object can qualify as a list even if its type is not
PyList_Type.  For such types, there's a Check() macro that does a more
sophisticated check.  They'll also have a CheckExact() macro doing an
exact type check; that'll look like PyWhatever_Check above.<br>
<br>
Then there's PyMethod.  PyMethod has a CheckExact macro but *doesn't*
have a Check macro.  Hmm!<br>
<br>
When I stumbled across that it got me to thinking.  Might it be a good
idea for all Python types to have both Check and CheckExact macros? 
The CheckExact form would be consistent, and for types that only need
an "exact" check they could define Check in terms of CheckExact:<br>
<blockquote>#define PyWhatever_CheckExact(ob) (Py_TYPE(ob) ==
&PyWhatever_Type)<br>
#define PyWhatever_Check PyWhatever_CheckExact</blockquote>
This would let you express your intent.  If you were expecting a
Whatever-like object, you always use Check.  If you require that exact
object, you always use CheckExact.<br>
<br>
On the other hand, maybe every type-checking macro that does
(Py_TYPE(ob) == &PyWhatever_Type) should be called CheckExact, and
for types that don't have an inexact check they don't have a Check.<br>
<br>
Or maybe the existing subclass-style Check macros should be renamed
CheckSubclass (or Implemented or something) and Check should always do
a CheckExact-style check.<br>
<br>
<br>
I admit this isn't a stupendous idea, but I thought it was worth typing
up.  If there's interest I'd be happy to supply a patch for whichever
form found favor.<br>
<br>
<br>
Or we could forget the whole thing, you and I,<br>
<br>
<br>
/larry/<br>
</body>
</html>