initial version of C int deque
- copy over dequeu from Cpython - and everything needed to compile Compile with cd typeddeque python3 setup.py install Signed-off-by: Csaba Kiraly <csaba.kiraly@gmail.com>
This commit is contained in:
parent
36d098cea3
commit
33ae50943d
|
@ -6,7 +6,8 @@ import logging
|
|||
from DAS.block import *
|
||||
from DAS.tools import shuffled, shuffledDict, unionOfSamples
|
||||
from bitarray.util import zeros
|
||||
from collections import deque
|
||||
#from collections import deque
|
||||
from typeddeque import deque
|
||||
from itertools import chain
|
||||
|
||||
class Neighbor:
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,72 @@
|
|||
/*[clinic input]
|
||||
preserve
|
||||
[clinic start generated code]*/
|
||||
|
||||
PyDoc_STRVAR(_collections__count_elements__doc__,
|
||||
"_count_elements($module, mapping, iterable, /)\n"
|
||||
"--\n"
|
||||
"\n"
|
||||
"Count elements in the iterable, updating the mapping");
|
||||
|
||||
#define _COLLECTIONS__COUNT_ELEMENTS_METHODDEF \
|
||||
{"_count_elements", _PyCFunction_CAST(_collections__count_elements), METH_FASTCALL, _collections__count_elements__doc__},
|
||||
|
||||
static PyObject *
|
||||
_collections__count_elements_impl(PyObject *module, PyObject *mapping,
|
||||
PyObject *iterable);
|
||||
|
||||
static PyObject *
|
||||
_collections__count_elements(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
|
||||
{
|
||||
PyObject *return_value = NULL;
|
||||
PyObject *mapping;
|
||||
PyObject *iterable;
|
||||
|
||||
if (!_PyArg_CheckPositional("_count_elements", nargs, 2, 2)) {
|
||||
goto exit;
|
||||
}
|
||||
mapping = args[0];
|
||||
iterable = args[1];
|
||||
return_value = _collections__count_elements_impl(module, mapping, iterable);
|
||||
|
||||
exit:
|
||||
return return_value;
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
tuplegetter_new_impl(PyTypeObject *type, Py_ssize_t index, PyObject *doc);
|
||||
|
||||
static PyObject *
|
||||
tuplegetter_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
|
||||
{
|
||||
PyObject *return_value = NULL;
|
||||
Py_ssize_t index;
|
||||
PyObject *doc;
|
||||
|
||||
if ((type == &tuplegetter_type ||
|
||||
type->tp_init == tuplegetter_type.tp_init) &&
|
||||
!_PyArg_NoKeywords("_tuplegetter", kwargs)) {
|
||||
goto exit;
|
||||
}
|
||||
if (!_PyArg_CheckPositional("_tuplegetter", PyTuple_GET_SIZE(args), 2, 2)) {
|
||||
goto exit;
|
||||
}
|
||||
{
|
||||
Py_ssize_t ival = -1;
|
||||
PyObject *iobj = _PyNumber_Index(PyTuple_GET_ITEM(args, 0));
|
||||
if (iobj != NULL) {
|
||||
ival = PyLong_AsSsize_t(iobj);
|
||||
Py_DECREF(iobj);
|
||||
}
|
||||
if (ival == -1 && PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
index = ival;
|
||||
}
|
||||
doc = PyTuple_GET_ITEM(args, 1);
|
||||
return_value = tuplegetter_new_impl(type, index, doc);
|
||||
|
||||
exit:
|
||||
return return_value;
|
||||
}
|
||||
/*[clinic end generated code: output=36b0948c4676c831 input=a9049054013a1b77]*/
|
|
@ -0,0 +1,12 @@
|
|||
from distutils.core import setup, Extension
|
||||
|
||||
def main():
|
||||
setup(name="typeddeque",
|
||||
version="0.0.1",
|
||||
description="typed deque classes",
|
||||
author="<Csaba Kiraly>",
|
||||
author_email="csaba.kiraly@gmail.com",
|
||||
ext_modules=[Extension("typeddeque", ["_collectionsmodule.c"])])
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
Loading…
Reference in New Issue