Nuitka
The Python compiler
Loading...
Searching...
No Matches
rangeobjects.h
1// Copyright 2025, Kay Hayen, mailto:kay.hayen@gmail.com find license text at end of file
2
3#ifndef __NUITKA_HELPER_RANGEOBJECTS_H__
4#define __NUITKA_HELPER_RANGEOBJECTS_H__
5
6/* For built-in built-in range() functionality. */
7
8extern PyObject *BUILTIN_RANGE3(PyThreadState *tstate, PyObject *low, PyObject *high, PyObject *step);
9extern PyObject *BUILTIN_RANGE2(PyThreadState *tstate, PyObject *low, PyObject *high);
10extern PyObject *BUILTIN_RANGE(PyThreadState *tstate, PyObject *boundary);
11
12/* For built-in built-in xrange() functionality. */
13extern PyObject *BUILTIN_XRANGE1(PyThreadState *tstate, PyObject *high);
14extern PyObject *BUILTIN_XRANGE2(PyThreadState *tstate, PyObject *low, PyObject *high);
15extern PyObject *BUILTIN_XRANGE3(PyThreadState *tstate, PyObject *low, PyObject *high, PyObject *step);
16
17#if PYTHON_VERSION >= 0x300
18
19/* Python3 range objects */
20struct _rangeobject3 {
21 /* Python object folklore: */
22 PyObject_HEAD
23
24 PyObject *start;
25 PyObject *stop;
26 PyObject *step;
27 PyObject *length;
28};
29
30NUITKA_MAY_BE_UNUSED static PyObject *PyRange_Start(PyObject *range) { return ((struct _rangeobject3 *)range)->start; }
31
32NUITKA_MAY_BE_UNUSED static PyObject *PyRange_Stop(PyObject *range) { return ((struct _rangeobject3 *)range)->stop; }
33
34NUITKA_MAY_BE_UNUSED static PyObject *PyRange_Step(PyObject *range) { return ((struct _rangeobject3 *)range)->step; }
35
36#else
37
39 /* Python object folklore: */
40 PyObject_HEAD
41
42 long start;
43 long step;
44 long len;
45};
46
47extern PyObject *MAKE_XRANGE(PyThreadState *tstate, long start, long stop, long step);
48
49#endif
50
51#endif
52
53// Part of "Nuitka", an optimizing Python compiler that is compatible and
54// integrates with CPython, but also works on its own.
55//
56// Licensed under the Apache License, Version 2.0 (the "License");
57// you may not use this file except in compliance with the License.
58// You may obtain a copy of the License at
59//
60// http://www.apache.org/licenses/LICENSE-2.0
61//
62// Unless required by applicable law or agreed to in writing, software
63// distributed under the License is distributed on an "AS IS" BASIS,
64// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
65// See the License for the specific language governing permissions and
66// limitations under the License.
Definition rangeobjects.h:38