cpython/Objects/boolobject.c

/* Boolean type, a subtype of int */

#include "Python.h"
#include "pycore_long.h"          // FALSE_TAG TRUE_TAG
#include "pycore_modsupport.h"    // _PyArg_NoKwnames()
#include "pycore_object.h"        // _Py_FatalRefcountError()
#include "pycore_runtime.h"       // _Py_ID()

#include <stddef.h>

/* We define bool_repr to return "False" or "True" */

static PyObject *
bool_repr(PyObject *self)
{}

/* Function to return a bool from a C long */

PyObject *PyBool_FromLong(long ok)
{}

/* We define bool_new to always return either Py_True or Py_False */

static PyObject *
bool_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
{}

static PyObject *
bool_vectorcall(PyObject *type, PyObject * const*args,
                size_t nargsf, PyObject *kwnames)
{}

/* Arithmetic operations redefined to return bool if both args are bool. */

static PyObject *
bool_invert(PyObject *v)
{}

static PyObject *
bool_and(PyObject *a, PyObject *b)
{}

static PyObject *
bool_or(PyObject *a, PyObject *b)
{}

static PyObject *
bool_xor(PyObject *a, PyObject *b)
{}

/* Doc string */

PyDoc_STRVAR(bool_doc,
"bool(object=False, /)\n\
--\n\
\n\
Returns True when the argument is true, False otherwise.\n\
The builtins True and False are the only two instances of the class bool.\n\
The class bool is a subclass of the class int, and cannot be subclassed.");

/* Arithmetic methods -- only so we can override &, |, ^. */

static PyNumberMethods bool_as_number =;

static void
bool_dealloc(PyObject *boolean)
{}

/* The type object for bool.  Note that this cannot be subclassed! */

PyTypeObject PyBool_Type =;

/* The objects representing bool values False and True */

struct _longobject _Py_FalseStruct =;

struct _longobject _Py_TrueStruct =;