(root)/
Python-3.12.0/
Modules/
clinic/
_randommodule.c.h
       1  /*[clinic input]
       2  preserve
       3  [clinic start generated code]*/
       4  
       5  #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
       6  #  include "pycore_gc.h"            // PyGC_Head
       7  #  include "pycore_runtime.h"       // _Py_ID()
       8  #endif
       9  
      10  
      11  PyDoc_STRVAR(_random_Random_random__doc__,
      12  "random($self, /)\n"
      13  "--\n"
      14  "\n"
      15  "random() -> x in the interval [0, 1).");
      16  
      17  #define _RANDOM_RANDOM_RANDOM_METHODDEF    \
      18      {"random", (PyCFunction)_random_Random_random, METH_NOARGS, _random_Random_random__doc__},
      19  
      20  static PyObject *
      21  _random_Random_random_impl(RandomObject *self);
      22  
      23  static PyObject *
      24  _random_Random_random(RandomObject *self, PyObject *Py_UNUSED(ignored))
      25  {
      26      return _random_Random_random_impl(self);
      27  }
      28  
      29  PyDoc_STRVAR(_random_Random_seed__doc__,
      30  "seed($self, n=None, /)\n"
      31  "--\n"
      32  "\n"
      33  "seed([n]) -> None.\n"
      34  "\n"
      35  "Defaults to use urandom and falls back to a combination\n"
      36  "of the current time and the process identifier.");
      37  
      38  #define _RANDOM_RANDOM_SEED_METHODDEF    \
      39      {"seed", _PyCFunction_CAST(_random_Random_seed), METH_FASTCALL, _random_Random_seed__doc__},
      40  
      41  static PyObject *
      42  _random_Random_seed_impl(RandomObject *self, PyObject *n);
      43  
      44  static PyObject *
      45  _random_Random_seed(RandomObject *self, PyObject *const *args, Py_ssize_t nargs)
      46  {
      47      PyObject *return_value = NULL;
      48      PyObject *n = Py_None;
      49  
      50      if (!_PyArg_CheckPositional("seed", nargs, 0, 1)) {
      51          goto exit;
      52      }
      53      if (nargs < 1) {
      54          goto skip_optional;
      55      }
      56      n = args[0];
      57  skip_optional:
      58      return_value = _random_Random_seed_impl(self, n);
      59  
      60  exit:
      61      return return_value;
      62  }
      63  
      64  PyDoc_STRVAR(_random_Random_getstate__doc__,
      65  "getstate($self, /)\n"
      66  "--\n"
      67  "\n"
      68  "getstate() -> tuple containing the current state.");
      69  
      70  #define _RANDOM_RANDOM_GETSTATE_METHODDEF    \
      71      {"getstate", (PyCFunction)_random_Random_getstate, METH_NOARGS, _random_Random_getstate__doc__},
      72  
      73  static PyObject *
      74  _random_Random_getstate_impl(RandomObject *self);
      75  
      76  static PyObject *
      77  _random_Random_getstate(RandomObject *self, PyObject *Py_UNUSED(ignored))
      78  {
      79      return _random_Random_getstate_impl(self);
      80  }
      81  
      82  PyDoc_STRVAR(_random_Random_setstate__doc__,
      83  "setstate($self, state, /)\n"
      84  "--\n"
      85  "\n"
      86  "setstate(state) -> None.  Restores generator state.");
      87  
      88  #define _RANDOM_RANDOM_SETSTATE_METHODDEF    \
      89      {"setstate", (PyCFunction)_random_Random_setstate, METH_O, _random_Random_setstate__doc__},
      90  
      91  PyDoc_STRVAR(_random_Random_getrandbits__doc__,
      92  "getrandbits($self, k, /)\n"
      93  "--\n"
      94  "\n"
      95  "getrandbits(k) -> x.  Generates an int with k random bits.");
      96  
      97  #define _RANDOM_RANDOM_GETRANDBITS_METHODDEF    \
      98      {"getrandbits", (PyCFunction)_random_Random_getrandbits, METH_O, _random_Random_getrandbits__doc__},
      99  
     100  static PyObject *
     101  _random_Random_getrandbits_impl(RandomObject *self, int k);
     102  
     103  static PyObject *
     104  _random_Random_getrandbits(RandomObject *self, PyObject *arg)
     105  {
     106      PyObject *return_value = NULL;
     107      int k;
     108  
     109      k = _PyLong_AsInt(arg);
     110      if (k == -1 && PyErr_Occurred()) {
     111          goto exit;
     112      }
     113      return_value = _random_Random_getrandbits_impl(self, k);
     114  
     115  exit:
     116      return return_value;
     117  }
     118  /*[clinic end generated code: output=bc17406a886824fc input=a9049054013a1b77]*/