8000 MAINT: Remove Python2 newbuffer getbuffer · numpy/numpy@2be9abe · GitHub
[go: up one dir, main page]

Skip to content

Commit 2be9abe

Browse files
committed
MAINT: Remove Python2 newbuffer getbuffer
1 parent c1f1bc9 commit 2be9abe

File tree

4 files changed

+2
-106
lines changed

4 files changed

+2
-106
lines changed

numpy/core/_add_newdocs.py

Lines changed: 2 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1034,7 +1034,7 @@
10341034
A string containing the data.
10351035
dtype : data-type, optional
10361036
The data type of the array; default: float. For binary input data,
1037-
the data must be in exactly this format. Most builtin numeric types are
1037+
the data must be in exactly this format. Most builtin numeric types are
10381038
supported and extension types may be supported.
10391039
10401040
.. versionadded:: 1.18.0
@@ -1484,59 +1484,6 @@
14841484
14851485
""")
14861486

1487-
if sys.version_info.major < 3:
1488-
add_newdoc('numpy.core.multiarray', 'newbuffer',
1489-
"""
1490-
newbuffer(size)
1491-
1492-
Return a new uninitialized buffer object.
1493-
1494-
Parameters
1495-
----------
1496-
size : int
1497-
Size in bytes of returned buffer object.
1498-
1499-
Returns
1500-
-------
1501-
newbuffer : buffer object
1502-
Returned, uninitialized buffer object of `size` bytes.
1503-
1504-
""")
1505-
1506-
add_newdoc('numpy.core.multiarray', 'getbuffer',
1507-
"""
1508-
getbuffer(obj [,offset[, size]])
1509-
1510-
Create a buffer object from the given object referencing a slice of
1511-
length size starting at offset.
1512-
1513-
Default is the entire buffer. A read-write buffer is attempted followed
1514-
by a read-only buffer.
1515-
1516-
Parameters
1517-
----------
1518-
obj : object
1519-
1520-
offset : int, optional
1521-
1522-
size : int, optional
1523-
1524-
Returns
1525-
-------
1526-
buffer_obj : buffer
1527-
1528-
Examples
1529-
--------
1530-
>>> buf = np.getbuffer(np.ones(5), 1, 3)
1531-
>>> len(buf)
1532-
3
1533-
>>> buf[0]
1534-
'\\x00'
1535-
>>> buf
1536-
<read-write buffer for 0x8af1e70, size 3, offset 1 at 0x8ba4ec0>
1537-
1538-
""")
1539-
15401487
add_newdoc('numpy.core.multiarray', 'c_einsum',
15411488
"""
15421489
c_einsum(subscripts, *operands, out=None, dtype=None, order='K',
@@ -3951,7 +3898,7 @@
39513898
39523899
Examples
39533900
--------
3954-
For a 1D array, ``a.tolist()`` is almost the same as ``list(a)``,
3901+
For a 1D array, ``a.tolist()`` is almost the same as ``list(a)``,
39553902
except that ``tolist`` changes numpy scalars to Python scalars:
39563903
39573904
>>> a = np.uint32([1, 2])

numpy/core/multiarray.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@
4141
'set_string_function', 'set_typeDict', 'shares_memory', 'test_interrupt',
4242
'tracemalloc_domain', 'typeinfo', 'unpackbits', 'unravel_index', 'vdot',
4343
'where', 'zeros']
44-
if sys.version_info.major < 3:
45-
__all__ += ['newbuffer', 'getbuffer']
4644

4745
# For backward compatibility, make sure pickle imports these functions from here
4846
_reconstruct.__module__ = 'numpy.core.multiarray'

numpy/core/numeric.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919
min_scalar_type, ndarray, nditer, nested_iters, promote_types,
2020
putmask, result_type, set_numeric_ops, shares_memory, vdot, where,
2121
zeros, normalize_axis_index)
22-
if sys.version_info[0] < 3:
23-
from .multiarray import newbuffer, getbuffer
2422

2523
from . import overrides
2624
from . import umath
@@ -65,9 +63,6 @@
6563
'matmul', 'shares_memory', 'may_share_memory', 'MAY_SHARE_BOUNDS',
6664
'MAY_SHARE_EXACT', 'TooHardError', 'AxisError']
6765

68-
if sys.version_info[0] < 3:
69-
__all__.extend(['getbuffer', 'newbuffer'])
70-
7166

7267
@set_module('numpy')
7368
class ComplexWarning(RuntimeWarning):

numpy/core/src/multiarray/multiarraymodule.c

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -3293,42 +3293,6 @@ array_datetime_data(PyObject *NPY_UNUSED(dummy), PyObject *args)
32933293
return convert_datetime_metadata_to_tuple(meta);
32943294
}
32953295

3296-
#if !defined(NPY_PY3K)
3297-
static PyObject *
3298-
new_buffer(PyObject *NPY_UNUSED(dummy), PyObject *args)
3299-
{
3300-
int size;
3301-
3302-
if (!PyArg_ParseTuple(args, "i:buffer", &size)) {
3303-
return NULL;
3304-
}
3305-
return PyBuffer_New(size);
3306-
}
3307-
3308-
static PyObject *
3309-
buffer_buffer(PyObject *NPY_UNUSED(dummy), PyObject *args, PyObject *kwds)
3310-
{
3311-
PyObject *obj;
3312-
Py_ssize_t offset = 0, n;
3313-
Py_ssize_t size = Py_END_OF_BUFFER;
3314-
void *unused;
3315-
static char *kwlist[] = {"object", "offset", "size", NULL};
3316-
3317-
if (!PyArg_ParseTupleAndKeywords(args, kwds,
3318-
"O|" NPY_SSIZE_T_PYFMT NPY_SSIZE_T_PYFMT ":get_buffer", kwlist,
3319-
&obj, &offset, &size)) {
3320-
return NULL;
3321-
}
3322-
if (PyObject_AsWriteBuffer(obj, &unused, &n) < 0) {
3323-
PyErr_Clear();
3324-
return PyBuffer_FromObject(obj, offset, size);
3325-
}
3326-
else {
3327-
return PyBuffer_FromReadWriteObject(obj, offset, size);
3328-
}
3329-
}
3330-
#endif
3331-
33323296
/*
33333297
* Prints floating-point scalars using the Dragon4 algorithm, scientific mode.
33343298
* See docstring of `np.format_float_scientific` for description of arguments.
@@ -4137,14 +4101,6 @@ static struct PyMethodDef array_module_methods[] = {
41374101
{"is_busday",
41384102
(PyCFunction)array_is_busday,
41394103
METH_VARARGS | METH_KEYWORDS, NULL},
4140-
#if !defined(NPY_PY3K)
4141-
{"newbuffer",
4142-
(PyCFunction)new_buffer,
4143-
METH_VARARGS, NULL},
4144-
{"getbuffer",
4145-
(PyCFunction)buffer_buffer,
4146-
METH_VARARGS | METH_KEYWORDS, NULL},
4147-
#endif
41484104
{"format_longfloat",
41494105
(PyCFunction)format_longfloat,
41504106
METH_VARARGS | METH_KEYWORDS, NULL},

0 commit comments

Comments
 (0)
0