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