Commit 2038bcb6 authored by Jason Madden's avatar Jason Madden

Reduce the boilerplate needed to add new tree types.

Generate the Python modules and test modules based off a description
of the datatype.

Several tests that were previously only used for a specific classes
are now generalized and added to most trees, such as testing
non-compliant keys and testing overflow for bounded values.

Also always raise ``OverflowError`` for integer keys/values out of range.
parent 3cbf0dcf
......@@ -57,7 +57,9 @@
** self The bucket
** keyarg The key to look for
** has_key Boolean; if true, return a true/false result; else return
** the value associated with the key.
** the value associated with the key. When true, ignore the TypeError from
** a key conversion issue, instead
** transforming it into a KeyError.
**
** Return
** If has_key:
......@@ -81,7 +83,15 @@ _bucket_get(Bucket *self, PyObject *keyarg, int has_key)
int copied = 1;
COPY_KEY_FROM_ARG(key, keyarg, copied);
UNLESS (copied) return NULL;
UNLESS (copied)
{
if (has_key && PyErr_ExceptionMatches(PyExc_TypeError))
{
PyErr_Clear();
PyErr_SetObject(PyExc_KeyError, keyarg);
}
return NULL;
}
UNLESS (PER_USE(self)) return NULL;
......@@ -106,7 +116,17 @@ Done:
static PyObject *
bucket_getitem(Bucket *self, PyObject *key)
{
return _bucket_get(self, key, 0);
PyObject* result;
result = _bucket_get(self, key, 0);
if (result == NULL && PyErr_ExceptionMatches(PyExc_TypeError))
{
PyErr_Clear();
PyErr_SetObject(PyExc_KeyError, key);
}
return result;
}
/*
......@@ -1448,6 +1468,10 @@ bucket_contains(Bucket *self, PyObject *key)
result = INT_AS_LONG(asobj) ? 1 : 0;
Py_DECREF(asobj);
}
else if (PyErr_ExceptionMatches(PyExc_KeyError)) {
PyErr_Clear();
result = 0;
}
return result;
}
......@@ -1465,6 +1489,10 @@ bucket_getm(Bucket *self, PyObject *args)
r = _bucket_get(self, key, 0);
if (r)
return r;
if (PyErr_ExceptionMatches(PyExc_TypeError)) {
PyErr_Clear();
PyErr_SetObject(PyExc_KeyError, key);
}
if (!PyErr_ExceptionMatches(PyExc_KeyError))
return NULL;
PyErr_Clear();
......
##############################################################################
#
# Copyright (c) 2001-2012 Zope Foundation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
#
##############################################################################
__all__ = ('Bucket', 'Set', 'BTree', 'TreeSet',
'IFBucket', 'IFSet', 'IFBTree', 'IFTreeSet',
'union', 'intersection', 'difference',
'weightedUnion', 'weightedIntersection', 'multiunion',
)
from zope.interface import moduleProvides
from .Interfaces import IIntegerFloatBTreeModule
from ._base import Bucket
from ._base import MERGE
from ._base import MERGE_WEIGHT_numeric
from ._base import MERGE_DEFAULT_float
from ._base import Set
from ._base import Tree as BTree
from ._base import TreeSet
from ._base import _TreeIterator
from ._base import difference as _difference
from ._base import intersection as _intersection
from ._base import multiunion as _multiunion
from ._base import set_operation as _set_operation
from ._base import to_int as _to_key
from ._base import to_float as _to_value
from ._base import union as _union
from ._base import weightedIntersection as _weightedIntersection
from ._base import weightedUnion as _weightedUnion
from ._base import _fix_pickle
from ._compat import import_c_extension
_BUCKET_SIZE = 120
_TREE_SIZE = 500
using64bits = False
class IFBucketPy(Bucket):
_to_key = _to_key
_to_value = _to_value
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_float
class IFSetPy(Set):
_to_key = _to_key
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_float
class IFBTreePy(BTree):
max_leaf_size = _BUCKET_SIZE
max_internal_size = _TREE_SIZE
_to_key = _to_key
_to_value = _to_value
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_float
class IFTreeSetPy(TreeSet):
max_leaf_size = _BUCKET_SIZE
max_internal_size = _TREE_SIZE
_to_key = _to_key
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_float
class IFTreeIteratorPy(_TreeIterator):
pass
# Can't declare forward refs, so fix up afterwards:
IFBucketPy._mapping_type = IFBucketPy._bucket_type = IFBucketPy
IFBucketPy._set_type = IFSetPy
IFSetPy._mapping_type = IFBucketPy
IFSetPy._set_type = IFSetPy._bucket_type = IFSetPy
IFBTreePy._mapping_type = IFBTreePy._bucket_type = IFBucketPy
IFBTreePy._set_type = IFSetPy
IFTreeSetPy._mapping_type = IFBucketPy
IFTreeSetPy._set_type = IFTreeSetPy._bucket_type = IFSetPy
differencePy = _set_operation(_difference, IFSetPy)
unionPy = _set_operation(_union, IFSetPy)
intersectionPy = _set_operation(_intersection, IFSetPy)
multiunionPy = _set_operation(_multiunion, IFSetPy)
weightedUnionPy = _set_operation(_weightedUnion, IFSetPy)
weightedIntersectionPy = _set_operation(_weightedIntersection, IFSetPy)
import_c_extension(globals())
_fix_pickle(globals(), __name__)
moduleProvides(IIntegerFloatBTreeModule)
##############################################################################
#
# Copyright (c) 2001-2012 Zope Foundation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
#
##############################################################################
__all__ = ('Bucket', 'Set', 'BTree', 'TreeSet',
'IIBucket', 'IISet', 'IIBTree', 'IITreeSet',
'union', 'intersection', 'difference',
'weightedUnion', 'weightedIntersection', 'multiunion',
)
from zope.interface import moduleProvides
from .Interfaces import IIntegerIntegerBTreeModule
from ._base import Bucket
from ._base import MERGE
from ._base import MERGE_WEIGHT_numeric
from ._base import MERGE_DEFAULT_int
from ._base import Set
from ._base import Tree as BTree
from ._base import TreeSet
from ._base import _TreeIterator
from ._base import difference as _difference
from ._base import intersection as _intersection
from ._base import multiunion as _multiunion
from ._base import set_operation as _set_operation
from ._base import to_int as _to_key
_to_value = _to_key
from ._base import union as _union
from ._base import weightedIntersection as _weightedIntersection
from ._base import weightedUnion as _weightedUnion
from ._base import _fix_pickle
from ._compat import import_c_extension
_BUCKET_SIZE = 120
_TREE_SIZE = 500
using64bits = False
class IIBucketPy(Bucket):
_to_key = _to_key
_to_value = _to_value
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_int
class IISetPy(Set):
_to_key = _to_key
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_int
class IIBTreePy(BTree):
max_leaf_size = _BUCKET_SIZE
max_internal_size = _TREE_SIZE
_to_key = _to_key
_to_value = _to_value
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_int
class IITreeSetPy(TreeSet):
max_leaf_size = _BUCKET_SIZE
max_internal_size = _TREE_SIZE
_to_key = _to_key
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_int
class IITreeIteratorPy(_TreeIterator):
pass
# Can't declare forward refs, so fix up afterwards:
IIBucketPy._mapping_type = IIBucketPy._bucket_type = IIBucketPy
IIBucketPy._set_type = IISetPy
IISetPy._mapping_type = IIBucketPy
IISetPy._set_type = IISetPy._bucket_type = IISetPy
IIBTreePy._mapping_type = IIBTreePy._bucket_type = IIBucketPy
IIBTreePy._set_type = IISetPy
IITreeSetPy._mapping_type = IIBucketPy
IITreeSetPy._set_type = IITreeSetPy._bucket_type = IISetPy
differencePy = _set_operation(_difference, IISetPy)
unionPy = _set_operation(_union, IISetPy)
intersectionPy = _set_operation(_intersection, IISetPy)
multiunionPy = _set_operation(_multiunion, IISetPy)
weightedUnionPy = _set_operation(_weightedUnion, IISetPy)
weightedIntersectionPy = _set_operation(_weightedIntersection, IISetPy)
import_c_extension(globals())
_fix_pickle(globals(), __name__)
moduleProvides(IIntegerIntegerBTreeModule)
##############################################################################
#
# Copyright (c) 2001-2012 Zope Foundation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
#
##############################################################################
__all__ = ('Bucket', 'Set', 'BTree', 'TreeSet',
'IOBucket', 'IOSet', 'IOBTree', 'IOTreeSet',
'union', 'intersection', 'difference', 'multiunion',
)
from zope.interface import moduleProvides
from .Interfaces import IIntegerObjectBTreeModule
from ._base import Bucket
from ._base import MERGE_WEIGHT_default
from ._base import Set
from ._base import Tree as BTree
from ._base import TreeSet
from ._base import _TreeIterator
from ._base import difference as _difference
from ._base import intersection as _intersection
from ._base import multiunion as _multiunion
from ._base import set_operation as _set_operation
from ._base import to_int as _to_key
from ._base import to_ob as _to_value
from ._base import union as _union
from ._base import _fix_pickle
from ._compat import import_c_extension
_BUCKET_SIZE = 60
_TREE_SIZE = 500
using64bits = False
class IOBucketPy(Bucket):
_to_key = _to_key
_to_value = _to_value
MERGE_WEIGHT = MERGE_WEIGHT_default
class IOSetPy(Set):
_to_key = _to_key
class IOBTreePy(BTree):
max_leaf_size = _BUCKET_SIZE
max_internal_size = _TREE_SIZE
_to_key = _to_key
_to_value = _to_value
MERGE_WEIGHT = MERGE_WEIGHT_default
class IOTreeSetPy(TreeSet):
max_leaf_size = _BUCKET_SIZE
max_internal_size = _TREE_SIZE
_to_key = _to_key
class IOTreeIteratorPy(_TreeIterator):
pass
# Can't declare forward refs, so fix up afterwards:
IOBucketPy._mapping_type = IOBucketPy._bucket_type = IOBucketPy
IOBucketPy._set_type = IOSetPy
IOSetPy._mapping_type = IOBucketPy
IOSetPy._set_type = IOSetPy._bucket_type = IOSetPy
IOBTreePy._mapping_type = IOBTreePy._bucket_type = IOBucketPy
IOBTreePy._set_type = IOSetPy
IOTreeSetPy._mapping_type = IOBucketPy
IOTreeSetPy._set_type = IOTreeSetPy._bucket_type = IOSetPy
differencePy = _set_operation(_difference, IOSetPy)
unionPy = _set_operation(_union, IOSetPy)
intersectionPy = _set_operation(_intersection, IOSetPy)
multiunionPy = _set_operation(_multiunion, IOSetPy)
import_c_extension(globals())
_fix_pickle(globals(), __name__)
moduleProvides(IIntegerObjectBTreeModule)
##############################################################################
#
# Copyright (c) 2001-2012 Zope Foundation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
#
##############################################################################
__all__ = ('Bucket', 'Set', 'BTree', 'TreeSet',
'IUBucket', 'IUSet', 'IUBTree', 'IUTreeSet',
'union', 'intersection', 'difference',
'weightedUnion', 'weightedIntersection', 'multiunion',
)
from zope.interface import moduleProvides
from .Interfaces import IIntegerUnsignedBTreeModule
from ._base import Bucket
from ._base import MERGE
from ._base import MERGE_WEIGHT_numeric
from ._base import MERGE_DEFAULT_int
from ._base import Set
from ._base import Tree as BTree
from ._base import TreeSet
from ._base import _TreeIterator
from ._base import difference as _difference
from ._base import intersection as _intersection
from ._base import multiunion as _multiunion
from ._base import set_operation as _set_operation
from ._base import to_int as _to_key
from ._base import to_uint as _to_value
from ._base import union as _union
from ._base import weightedIntersection as _weightedIntersection
from ._base import weightedUnion as _weightedUnion
from ._base import _fix_pickle
from ._compat import import_c_extension
_BUCKET_SIZE = 120
_TREE_SIZE = 500
using64bits = False
class IUBucketPy(Bucket):
_to_key = _to_key
_to_value = _to_value
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_int
class IUSetPy(Set):
_to_key = _to_key
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_int
class IUBTreePy(BTree):
max_leaf_size = _BUCKET_SIZE
max_internal_size = _TREE_SIZE
_to_key = _to_key
_to_value = _to_value
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_int
class IUTreeSetPy(TreeSet):
max_leaf_size = _BUCKET_SIZE
max_internal_size = _TREE_SIZE
_to_key = _to_key
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_int
class IUTreeIteratorPy(_TreeIterator):
pass
# Can't declare forward refs, so fix up afterwards:
IUBucketPy._mapping_type = IUBucketPy._bucket_type = IUBucketPy
IUBucketPy._set_type = IUSetPy
IUSetPy._mapping_type = IUBucketPy
IUSetPy._set_type = IUSetPy._bucket_type = IUSetPy
IUBTreePy._mapping_type = IUBTreePy._bucket_type = IUBucketPy
IUBTreePy._set_type = IUSetPy
IUTreeSetPy._mapping_type = IUBucketPy
IUTreeSetPy._set_type = IUTreeSetPy._bucket_type = IUSetPy
differencePy = _set_operation(_difference, IUSetPy)
unionPy = _set_operation(_union, IUSetPy)
intersectionPy = _set_operation(_intersection, IUSetPy)
multiunionPy = _set_operation(_multiunion, IUSetPy)
weightedUnionPy = _set_operation(_weightedUnion, IUSetPy)
weightedIntersectionPy = _set_operation(_weightedIntersection, IUSetPy)
import_c_extension(globals())
_fix_pickle(globals(), __name__)
moduleProvides(IIntegerUnsignedBTreeModule)
##############################################################################
#
# Copyright (c) 2001-2012 Zope Foundation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
#
##############################################################################
__all__ = ('Bucket', 'Set', 'BTree', 'TreeSet',
'LFBucket', 'LFSet', 'LFBTree', 'LFTreeSet',
'union', 'intersection', 'difference',
'weightedUnion', 'weightedIntersection', 'multiunion',
)
from zope.interface import moduleProvides
from .Interfaces import IIntegerFloatBTreeModule
from ._base import Bucket
from ._base import MERGE
from ._base import MERGE_WEIGHT_numeric
from ._base import MERGE_DEFAULT_float
from ._base import Set
from ._base import Tree as BTree
from ._base import TreeSet
from ._base import _TreeIterator
from ._base import difference as _difference
from ._base import intersection as _intersection
from ._base import multiunion as _multiunion
from ._base import set_operation as _set_operation
from ._base import to_long as _to_key
from ._base import to_float as _to_value
from ._base import union as _union
from ._base import weightedIntersection as _weightedIntersection
from ._base import weightedUnion as _weightedUnion
from ._base import _fix_pickle
from ._compat import import_c_extension
_BUCKET_SIZE = 120
_TREE_SIZE = 500
using64bits = True
class LFBucketPy(Bucket):
_to_key = _to_key
_to_value = _to_value
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_float
class LFSetPy(Set):
_to_key = _to_key
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_float
class LFBTreePy(BTree):
max_leaf_size = _BUCKET_SIZE
max_internal_size = _TREE_SIZE
_to_key = _to_key
_to_value = _to_value
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_float
class LFTreeSetPy(TreeSet):
max_leaf_size = _BUCKET_SIZE
max_internal_size = _TREE_SIZE
_to_key = _to_key
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_float
class LFTreeIteratorPy(_TreeIterator):
pass
# Can't declare forward refs, so fix up afterwards:
LFBucketPy._mapping_type = LFBucketPy._bucket_type = LFBucketPy
LFBucketPy._set_type = LFSetPy
LFSetPy._mapping_type = LFBucketPy
LFSetPy._set_type = LFSetPy._bucket_type = LFSetPy
LFBTreePy._mapping_type = LFBTreePy._bucket_type = LFBucketPy
LFBTreePy._set_type = LFSetPy
LFTreeSetPy._mapping_type = LFBucketPy
LFTreeSetPy._set_type = LFTreeSetPy._bucket_type = LFSetPy
differencePy = _set_operation(_difference, LFSetPy)
unionPy = _set_operation(_union, LFSetPy)
intersectionPy = _set_operation(_intersection, LFSetPy)
multiunionPy = _set_operation(_multiunion, LFSetPy)
weightedUnionPy = _set_operation(_weightedUnion, LFSetPy)
weightedIntersectionPy = _set_operation(_weightedIntersection, LFSetPy)
import_c_extension(globals())
_fix_pickle(globals(), __name__)
moduleProvides(IIntegerFloatBTreeModule)
##############################################################################
#
# Copyright (c) 2001-2012 Zope Foundation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
#
##############################################################################
__all__ = ('Bucket', 'Set', 'BTree', 'TreeSet',
'LLBucket', 'LLSet', 'LLBTree', 'LLTreeSet',
'union', 'intersection', 'difference',
'weightedUnion', 'weightedIntersection', 'multiunion',
)
from zope.interface import moduleProvides
from .Interfaces import IIntegerIntegerBTreeModule
from ._base import Bucket
from ._base import MERGE
from ._base import MERGE_WEIGHT_numeric
from ._base import MERGE_DEFAULT_int
from ._base import Set
from ._base import Tree as BTree
from ._base import TreeSet
from ._base import _TreeIterator
from ._base import difference as _difference
from ._base import intersection as _intersection
from ._base import multiunion as _multiunion
from ._base import set_operation as _set_operation
from ._base import to_long as _to_key
from ._base import to_long as _to_value
from ._base import union as _union
from ._base import weightedIntersection as _weightedIntersection
from ._base import weightedUnion as _weightedUnion
from ._base import _fix_pickle
from ._compat import import_c_extension
_BUCKET_SIZE = 120
_TREE_SIZE = 500
using64bits = True
class LLBucketPy(Bucket):
_to_key = _to_key
_to_value = _to_value
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_int
class LLSetPy(Set):
_to_key = _to_key
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_int
class LLBTreePy(BTree):
max_leaf_size = _BUCKET_SIZE
max_internal_size = _TREE_SIZE
_to_key = _to_key
_to_value = _to_value
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_int
class LLTreeSetPy(TreeSet):
max_leaf_size = _BUCKET_SIZE
max_internal_size = _TREE_SIZE
_to_key = _to_key
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_int
class LLTreeIteratorPy(_TreeIterator):
pass
# Can't declare forward refs, so fix up afterwards:
LLBucketPy._mapping_type = LLBucketPy._bucket_type = LLBucketPy
LLBucketPy._set_type = LLSetPy
LLSetPy._mapping_type = LLBucketPy
LLSetPy._set_type = LLSetPy._bucket_type = LLSetPy
LLBTreePy._mapping_type = LLBTreePy._bucket_type = LLBucketPy
LLBTreePy._set_type = LLSetPy
LLTreeSetPy._mapping_type = LLBucketPy
LLTreeSetPy._set_type = LLTreeSetPy._bucket_type = LLSetPy
differencePy = _set_operation(_difference, LLSetPy)
unionPy = _set_operation(_union, LLSetPy)
intersectionPy = _set_operation(_intersection, LLSetPy)
multiunionPy = _set_operation(_multiunion, LLSetPy)
weightedUnionPy = _set_operation(_weightedUnion, LLSetPy)
weightedIntersectionPy = _set_operation(_weightedIntersection, LLSetPy)
import_c_extension(globals())
_fix_pickle(globals(), __name__)
moduleProvides(IIntegerIntegerBTreeModule)
##############################################################################
#
# Copyright (c) 2001-2012 Zope Foundation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
#
##############################################################################
__all__ = ('Bucket', 'Set', 'BTree', 'TreeSet',
'LOBucket', 'LOSet', 'LOBTree', 'LOTreeSet',
'union', 'intersection', 'difference', 'multiunion',
)
from zope.interface import moduleProvides
from .Interfaces import IIntegerObjectBTreeModule
from ._base import Bucket
from ._base import MERGE_WEIGHT_default
from ._base import Set
from ._base import Tree as BTree
from ._base import TreeSet
from ._base import _TreeIterator
from ._base import difference as _difference
from ._base import intersection as _intersection
from ._base import multiunion as _multiunion
from ._base import set_operation as _set_operation
from ._base import to_long as _to_key
from ._base import to_ob as _to_value
from ._base import union as _union
from ._base import _fix_pickle
from ._compat import import_c_extension
_BUCKET_SIZE = 60
_TREE_SIZE = 500
using64bits = True
class LOBucketPy(Bucket):
_to_key = _to_key
_to_value = _to_value
MERGE_WEIGHT = MERGE_WEIGHT_default
class LOSetPy(Set):
_to_key = _to_key
class LOBTreePy(BTree):
max_leaf_size = _BUCKET_SIZE
max_internal_size = _TREE_SIZE
_to_key = _to_key
_to_value = _to_value
MERGE_WEIGHT = MERGE_WEIGHT_default
class LOTreeSetPy(TreeSet):
max_leaf_size = _BUCKET_SIZE
max_internal_size = _TREE_SIZE
_to_key = _to_key
class LOTreeIteratorPy(_TreeIterator):
pass
# Can't declare forward refs, so fix up afterwards:
LOBucketPy._mapping_type = LOBucketPy._bucket_type = LOBucketPy
LOBucketPy._set_type = LOSetPy
LOSetPy._mapping_type = LOBucketPy
LOSetPy._set_type = LOSetPy._bucket_type = LOSetPy
LOBTreePy._mapping_type = LOBTreePy._bucket_type = LOBucketPy
LOBTreePy._set_type = LOSetPy
LOTreeSetPy._mapping_type = LOBucketPy
LOTreeSetPy._set_type = LOTreeSetPy._bucket_type = LOSetPy
differencePy = _set_operation(_difference, LOSetPy)
unionPy = _set_operation(_union, LOSetPy)
intersectionPy = _set_operation(_intersection, LOSetPy)
multiunionPy = _set_operation(_multiunion, LOSetPy)
import_c_extension(globals())
_fix_pickle(globals(), __name__)
moduleProvides(IIntegerObjectBTreeModule)
##############################################################################
#
# Copyright (c) 2001-2012 Zope Foundation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
#
##############################################################################
__all__ = ('Bucket', 'Set', 'BTree', 'TreeSet',
'LQBucket', 'LQSet', 'LQBTree', 'LQTreeSet',
'union', 'intersection', 'difference',
'weightedUnion', 'weightedIntersection', 'multiunion',
)
from zope.interface import moduleProvides
from .Interfaces import IIntegerUnsignedBTreeModule
from ._base import Bucket
from ._base import MERGE
from ._base import MERGE_WEIGHT_numeric
from ._base import MERGE_DEFAULT_int
from ._base import Set
from ._base import Tree as BTree
from ._base import TreeSet
from ._base import _TreeIterator
from ._base import difference as _difference
from ._base import intersection as _intersection
from ._base import multiunion as _multiunion
from ._base import set_operation as _set_operation
from ._base import to_long as _to_key
from ._base import to_ulong as _to_value
from ._base import union as _union
from ._base import weightedIntersection as _weightedIntersection
from ._base import weightedUnion as _weightedUnion
from ._base import _fix_pickle
from ._compat import import_c_extension
_BUCKET_SIZE = 120
_TREE_SIZE = 500
using64bits = True
class LQBucketPy(Bucket):
_to_key = _to_key
_to_value = _to_value
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_int
class LQSetPy(Set):
_to_key = _to_key
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_int
class LQBTreePy(BTree):
max_leaf_size = _BUCKET_SIZE
max_internal_size = _TREE_SIZE
_to_key = _to_key
_to_value = _to_value
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_int
class LQTreeSetPy(TreeSet):
max_leaf_size = _BUCKET_SIZE
max_internal_size = _TREE_SIZE
_to_key = _to_key
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_int
class LQTreeIteratorPy(_TreeIterator):
pass
# Can't declare forward refs, so fix up afterwards:
LQBucketPy._mapping_type = LQBucketPy._bucket_type = LQBucketPy
LQBucketPy._set_type = LQSetPy
LQSetPy._mapping_type = LQBucketPy
LQSetPy._set_type = LQSetPy._bucket_type = LQSetPy
LQBTreePy._mapping_type = LQBTreePy._bucket_type = LQBucketPy
LQBTreePy._set_type = LQSetPy
LQTreeSetPy._mapping_type = LQBucketPy
LQTreeSetPy._set_type = LQTreeSetPy._bucket_type = LQSetPy
differencePy = _set_operation(_difference, LQSetPy)
unionPy = _set_operation(_union, LQSetPy)
intersectionPy = _set_operation(_intersection, LQSetPy)
multiunionPy = _set_operation(_multiunion, LQSetPy)
weightedUnionPy = _set_operation(_weightedUnion, LQSetPy)
weightedIntersectionPy = _set_operation(_weightedIntersection, LQSetPy)
import_c_extension(globals())
_fix_pickle(globals(), __name__)
moduleProvides(IIntegerUnsignedBTreeModule)
##############################################################################
#
# Copyright (c) 2001-2012 Zope Foundation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
#
##############################################################################
__all__ = ('Bucket', 'Set', 'BTree', 'TreeSet',
'OIBucket', 'OISet', 'OIBTree', 'OITreeSet',
'union', 'intersection', 'difference',
'weightedUnion', 'weightedIntersection',
)
from zope.interface import moduleProvides
from .Interfaces import IObjectIntegerBTreeModule
from ._base import Bucket
from ._base import MERGE
from ._base import MERGE_WEIGHT_numeric
from ._base import MERGE_DEFAULT_float
from ._base import Set
from ._base import Tree as BTree
from ._base import TreeSet
from ._base import _TreeIterator
from ._base import difference as _difference
from ._base import intersection as _intersection
from ._base import set_operation as _set_operation
from ._base import to_ob as _to_key
from ._base import to_int as _to_value
from ._base import union as _union
from ._base import weightedIntersection as _weightedIntersection
from ._base import weightedUnion as _weightedUnion
from ._base import _fix_pickle
from ._compat import import_c_extension
_BUCKET_SIZE = 60
_TREE_SIZE = 250
using64bits = False
class OIBucketPy(Bucket):
_to_key = _to_key
_to_value = _to_value
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_float
class OISetPy(Set):
_to_key = _to_key
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_float
class OIBTreePy(BTree):
max_leaf_size = _BUCKET_SIZE
max_internal_size = _TREE_SIZE
_to_key = _to_key
_to_value = _to_value
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_float
class OITreeSetPy(TreeSet):
max_leaf_size = _BUCKET_SIZE
max_internal_size = _TREE_SIZE
_to_key = _to_key
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_float
class OITreeIteratorPy(_TreeIterator):
pass
# Can't declare forward refs, so fix up afterwards:
OIBucketPy._mapping_type = OIBucketPy._bucket_type = OIBucketPy
OIBucketPy._set_type = OISetPy
OISetPy._mapping_type = OIBucketPy
OISetPy._set_type = OISetPy._bucket_type = OISetPy
OIBTreePy._mapping_type = OIBTreePy._bucket_type = OIBucketPy
OIBTreePy._set_type = OISetPy
OITreeSetPy._mapping_type = OIBucketPy
OITreeSetPy._set_type = OITreeSetPy._bucket_type = OISetPy
differencePy = _set_operation(_difference, OISetPy)
unionPy = _set_operation(_union, OISetPy)
intersectionPy = _set_operation(_intersection, OISetPy)
weightedUnionPy = _set_operation(_weightedUnion, OISetPy)
weightedIntersectionPy = _set_operation(_weightedIntersection, OISetPy)
import_c_extension(globals())
_fix_pickle(globals(), __name__)
moduleProvides(IObjectIntegerBTreeModule)
##############################################################################
#
# Copyright (c) 2001-2012 Zope Foundation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
#
##############################################################################
__all__ = ('Bucket', 'Set', 'BTree', 'TreeSet',
'OLBucket', 'OLSet', 'OLBTree', 'OLTreeSet',
'union', 'intersection', 'difference',
'weightedUnion', 'weightedIntersection',
)
from zope.interface import moduleProvides
from .Interfaces import IObjectIntegerBTreeModule
from ._base import Bucket
from ._base import MERGE
from ._base import MERGE_WEIGHT_numeric
from ._base import MERGE_DEFAULT_int
from ._base import Set
from ._base import Tree as BTree
from ._base import TreeSet
from ._base import _TreeIterator
from ._base import difference as _difference
from ._base import intersection as _intersection
from ._base import set_operation as _set_operation
from ._base import to_ob as _to_key
from ._base import to_long as _to_value
from ._base import union as _union
from ._base import weightedIntersection as _weightedIntersection
from ._base import weightedUnion as _weightedUnion
from ._base import _fix_pickle
from ._compat import import_c_extension
_BUCKET_SIZE = 60
_TREE_SIZE = 250
using64bits = True
class OLBucketPy(Bucket):
_to_key = _to_key
_to_value = _to_value
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_int
class OLSetPy(Set):
_to_key = _to_key
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_int
class OLBTreePy(BTree):
max_leaf_size = _BUCKET_SIZE
max_internal_size = _TREE_SIZE
_to_key = _to_key
_to_value = _to_value
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_int
class OLTreeSetPy(TreeSet):
max_leaf_size = _BUCKET_SIZE
max_internal_size = _TREE_SIZE
_to_key = _to_key
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_int
class OLTreeIteratorPy(_TreeIterator):
pass
# Can't declare forward refs, so fix up afterwards:
OLBucketPy._mapping_type = OLBucketPy._bucket_type = OLBucketPy
OLBucketPy._set_type = OLSetPy
OLSetPy._mapping_type = OLBucketPy
OLSetPy._set_type = OLSetPy._bucket_type = OLSetPy
OLBTreePy._mapping_type = OLBTreePy._bucket_type = OLBucketPy
OLBTreePy._set_type = OLSetPy
OLTreeSetPy._mapping_type = OLBucketPy
OLTreeSetPy._set_type = OLTreeSetPy._bucket_type = OLSetPy
differencePy = _set_operation(_difference, OLSetPy)
unionPy = _set_operation(_union, OLSetPy)
intersectionPy = _set_operation(_intersection, OLSetPy)
weightedUnionPy = _set_operation(_weightedUnion, OLSetPy)
weightedIntersectionPy = _set_operation(_weightedIntersection, OLSetPy)
import_c_extension(globals())
_fix_pickle(globals(), __name__)
moduleProvides(IObjectIntegerBTreeModule)
##############################################################################
#
# Copyright (c) 2001-2012 Zope Foundation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
#
##############################################################################
__all__ = ('Bucket', 'Set', 'BTree', 'TreeSet',
'OOBucket', 'OOSet', 'OOBTree', 'OOTreeSet',
'union', 'intersection','difference',
)
from zope.interface import moduleProvides
from .Interfaces import IObjectObjectBTreeModule
from ._base import Bucket
from ._base import Set
from ._base import Tree as BTree
from ._base import TreeSet
from ._base import _TreeIterator
from ._base import difference as _difference
from ._base import intersection as _intersection
from ._base import set_operation as _set_operation
from ._base import to_ob as _to_key
_to_value = _to_key
from ._base import union as _union
from ._base import _fix_pickle
from ._compat import import_c_extension
_BUCKET_SIZE = 30
_TREE_SIZE = 250
using64bits = False
class OOBucketPy(Bucket):
_to_key = _to_key
_to_value = _to_value
class OOSetPy(Set):
_to_key = _to_key
class OOBTreePy(BTree):
max_leaf_size = _BUCKET_SIZE
max_internal_size = _TREE_SIZE
_to_key = _to_key
_to_value = _to_value
class OOTreeSetPy(TreeSet):
max_leaf_size = _BUCKET_SIZE
max_internal_size = _TREE_SIZE
_to_key = _to_key
class OOTreeIteratorPy(_TreeIterator):
pass
# Can't declare forward refs, so fix up afterwards:
OOBucketPy._mapping_type = OOBucketPy._bucket_type = OOBucketPy
OOBucketPy._set_type = OOSetPy
OOSetPy._mapping_type = OOBucketPy
OOSetPy._set_type = OOSetPy._bucket_type = OOSetPy
OOBTreePy._mapping_type = OOBTreePy._bucket_type = OOBucketPy
OOBTreePy._set_type = OOSetPy
OOTreeSetPy._mapping_type = OOBucketPy
OOTreeSetPy._set_type = OOTreeSetPy._bucket_type = OOSetPy
differencePy = _set_operation(_difference, OOSetPy)
unionPy = _set_operation(_union, OOSetPy)
intersectionPy = _set_operation(_intersection, OOSetPy)
import_c_extension(globals())
_fix_pickle(globals(), __name__)
moduleProvides(IObjectObjectBTreeModule)
##############################################################################
#
# Copyright (c) 2001-2012 Zope Foundation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
#
##############################################################################
__all__ = ('Bucket', 'Set', 'BTree', 'TreeSet',
'OQBucket', 'OQSet', 'OQBTree', 'OQTreeSet',
'union', 'intersection', 'difference',
'weightedUnion', 'weightedIntersection',
)
from zope.interface import moduleProvides
from .Interfaces import IObjectUnsignedBTreeModule
from ._base import Bucket
from ._base import MERGE
from ._base import MERGE_WEIGHT_numeric
from ._base import MERGE_DEFAULT_int
from ._base import Set
from ._base import Tree as BTree
from ._base import TreeSet
from ._base import _TreeIterator
from ._base import difference as _difference
from ._base import intersection as _intersection
from ._base import set_operation as _set_operation
from ._base import to_ob as _to_key
from ._base import to_ulong as _to_value
from ._base import union as _union
from ._base import weightedIntersection as _weightedIntersection
from ._base import weightedUnion as _weightedUnion
from ._base import _fix_pickle
from ._compat import import_c_extension
_BUCKET_SIZE = 60
_TREE_SIZE = 250
using64bits = True
class OQBucketPy(Bucket):
_to_key = _to_key
_to_value = _to_value
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_int
class OQSetPy(Set):
_to_key = _to_key
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_int
class OQBTreePy(BTree):
max_leaf_size = _BUCKET_SIZE
max_internal_size = _TREE_SIZE
_to_key = _to_key
_to_value = _to_value
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_int
class OQTreeSetPy(TreeSet):
max_leaf_size = _BUCKET_SIZE
max_internal_size = _TREE_SIZE
_to_key = _to_key
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_int
class OQTreeIteratorPy(_TreeIterator):
pass
# Can't declare forward refs, so fix up afterwards:
OQBucketPy._mapping_type = OQBucketPy._bucket_type = OQBucketPy
OQBucketPy._set_type = OQSetPy
OQSetPy._mapping_type = OQBucketPy
OQSetPy._set_type = OQSetPy._bucket_type = OQSetPy
OQBTreePy._mapping_type = OQBTreePy._bucket_type = OQBucketPy
OQBTreePy._set_type = OQSetPy
OQTreeSetPy._mapping_type = OQBucketPy
OQTreeSetPy._set_type = OQTreeSetPy._bucket_type = OQSetPy
differencePy = _set_operation(_difference, OQSetPy)
unionPy = _set_operation(_union, OQSetPy)
intersectionPy = _set_operation(_intersection, OQSetPy)
weightedUnionPy = _set_operation(_weightedUnion, OQSetPy)
weightedIntersectionPy = _set_operation(_weightedIntersection, OQSetPy)
import_c_extension(globals())
_fix_pickle(globals(), __name__)
moduleProvides(IObjectUnsignedBTreeModule)
##############################################################################
#
# Copyright (c) 2001-2012 Zope Foundation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
#
##############################################################################
__all__ = ('Bucket', 'Set', 'BTree', 'TreeSet',
'OUBucket', 'OUSet', 'OUBTree', 'OUTreeSet',
'union', 'intersection', 'difference',
'weightedUnion', 'weightedIntersection',
)
from zope.interface import moduleProvides
from .Interfaces import IObjectUnsignedBTreeModule
from ._base import Bucket
from ._base import MERGE
from ._base import MERGE_WEIGHT_numeric
from ._base import MERGE_DEFAULT_float
from ._base import Set
from ._base import Tree as BTree
from ._base import TreeSet
from ._base import _TreeIterator
from ._base import difference as _difference
from ._base import intersection as _intersection
from ._base import set_operation as _set_operation
from ._base import to_ob as _to_key
from ._base import to_uint as _to_value
from ._base import union as _union
from ._base import weightedIntersection as _weightedIntersection
from ._base import weightedUnion as _weightedUnion
from ._base import _fix_pickle
from ._compat import import_c_extension
_BUCKET_SIZE = 60
_TREE_SIZE = 250
using64bits = True
class OUBucketPy(Bucket):
_to_key = _to_key
_to_value = _to_value
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_float
class OUSetPy(Set):
_to_key = _to_key
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_float
class OUBTreePy(BTree):
max_leaf_size = _BUCKET_SIZE
max_internal_size = _TREE_SIZE
_to_key = _to_key
_to_value = _to_value
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_float
class OUTreeSetPy(TreeSet):
max_leaf_size = _BUCKET_SIZE
max_internal_size = _TREE_SIZE
_to_key = _to_key
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_float
class OUTreeIteratorPy(_TreeIterator):
pass
# Can't declare forward refs, so fix up afterwards:
OUBucketPy._mapping_type = OUBucketPy._bucket_type = OUBucketPy
OUBucketPy._set_type = OUSetPy
OUSetPy._mapping_type = OUBucketPy
OUSetPy._set_type = OUSetPy._bucket_type = OUSetPy
OUBTreePy._mapping_type = OUBTreePy._bucket_type = OUBucketPy
OUBTreePy._set_type = OUSetPy
OUTreeSetPy._mapping_type = OUBucketPy
OUTreeSetPy._set_type = OUTreeSetPy._bucket_type = OUSetPy
differencePy = _set_operation(_difference, OUSetPy)
unionPy = _set_operation(_union, OUSetPy)
intersectionPy = _set_operation(_intersection, OUSetPy)
weightedUnionPy = _set_operation(_weightedUnion, OUSetPy)
weightedIntersectionPy = _set_operation(_weightedIntersection, OUSetPy)
import_c_extension(globals())
_fix_pickle(globals(), __name__)
moduleProvides(IObjectUnsignedBTreeModule)
##############################################################################
#
# Copyright (c) 2001-2012 Zope Foundation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
#
##############################################################################
__all__ = ('Bucket', 'Set', 'BTree', 'TreeSet',
'QFBucket', 'QFSet', 'QFBTree', 'QFTreeSet',
'union', 'intersection', 'difference',
'weightedUnion', 'weightedIntersection', 'multiunion',
)
from zope.interface import moduleProvides
from .Interfaces import IUnsignedFloatBTreeModule
from ._base import Bucket
from ._base import MERGE
from ._base import MERGE_WEIGHT_numeric
from ._base import MERGE_DEFAULT_float
from ._base import Set
from ._base import Tree as BTree
from ._base import TreeSet
from ._base import _TreeIterator
from ._base import difference as _difference
from ._base import intersection as _intersection
from ._base import multiunion as _multiunion
from ._base import set_operation as _set_operation
from ._base import to_ulong as _to_key
from ._base import to_float as _to_value
from ._base import union as _union
from ._base import weightedIntersection as _weightedIntersection
from ._base import weightedUnion as _weightedUnion
from ._base import _fix_pickle
from ._compat import import_c_extension
_BUCKET_SIZE = 120
_TREE_SIZE = 500
using64bits = True
class QFBucketPy(Bucket):
_to_key = _to_key
_to_value = _to_value
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_float
class QFSetPy(Set):
_to_key = _to_key
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_float
class QFBTreePy(BTree):
max_leaf_size = _BUCKET_SIZE
max_internal_size = _TREE_SIZE
_to_key = _to_key
_to_value = _to_value
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_float
class QFTreeSetPy(TreeSet):
max_leaf_size = _BUCKET_SIZE
max_internal_size = _TREE_SIZE
_to_key = _to_key
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_float
class QFTreeIteratorPy(_TreeIterator):
pass
# Can't declare forward refs, so fix up afterwards:
QFBucketPy._mapping_type = QFBucketPy._bucket_type = QFBucketPy
QFBucketPy._set_type = QFSetPy
QFSetPy._mapping_type = QFBucketPy
QFSetPy._set_type = QFSetPy._bucket_type = QFSetPy
QFBTreePy._mapping_type = QFBTreePy._bucket_type = QFBucketPy
QFBTreePy._set_type = QFSetPy
QFTreeSetPy._mapping_type = QFBucketPy
QFTreeSetPy._set_type = QFTreeSetPy._bucket_type = QFSetPy
differencePy = _set_operation(_difference, QFSetPy)
unionPy = _set_operation(_union, QFSetPy)
intersectionPy = _set_operation(_intersection, QFSetPy)
multiunionPy = _set_operation(_multiunion, QFSetPy)
weightedUnionPy = _set_operation(_weightedUnion, QFSetPy)
weightedIntersectionPy = _set_operation(_weightedIntersection, QFSetPy)
import_c_extension(globals())
_fix_pickle(globals(), __name__)
moduleProvides(IUnsignedFloatBTreeModule)
##############################################################################
#
# Copyright (c) 2001-2012 Zope Foundation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
#
##############################################################################
__all__ = ('Bucket', 'Set', 'BTree', 'TreeSet',
'QLBucket', 'QLSet', 'QLBTree', 'QLTreeSet',
'union', 'intersection', 'difference',
'weightedUnion', 'weightedIntersection', 'multiunion',
)
from zope.interface import moduleProvides
from .Interfaces import IUnsignedIntegerBTreeModule
from ._base import Bucket
from ._base import MERGE
from ._base import MERGE_WEIGHT_numeric
from ._base import MERGE_DEFAULT_int
from ._base import Set
from ._base import Tree as BTree
from ._base import TreeSet
from ._base import _TreeIterator
from ._base import difference as _difference
from ._base import intersection as _intersection
from ._base import multiunion as _multiunion
from ._base import set_operation as _set_operation
from ._base import to_ulong as _to_key
from ._base import to_long as _to_value
from ._base import union as _union
from ._base import weightedIntersection as _weightedIntersection
from ._base import weightedUnion as _weightedUnion
from ._base import _fix_pickle
from ._compat import import_c_extension
_BUCKET_SIZE = 120
_TREE_SIZE = 500
using64bits = True
class QLBucketPy(Bucket):
_to_key = _to_key
_to_value = _to_value
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_int
class QLSetPy(Set):
_to_key = _to_key
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_int
class QLBTreePy(BTree):
max_leaf_size = _BUCKET_SIZE
max_internal_size = _TREE_SIZE
_to_key = _to_key
_to_value = _to_value
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_int
class QLTreeSetPy(TreeSet):
max_leaf_size = _BUCKET_SIZE
max_internal_size = _TREE_SIZE
_to_key = _to_key
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_int
class QLTreeIteratorPy(_TreeIterator):
pass
# Can't declare forward refs, so fix up afterwards:
QLBucketPy._mapping_type = QLBucketPy._bucket_type = QLBucketPy
QLBucketPy._set_type = QLSetPy
QLSetPy._mapping_type = QLBucketPy
QLSetPy._set_type = QLSetPy._bucket_type = QLSetPy
QLBTreePy._mapping_type = QLBTreePy._bucket_type = QLBucketPy
QLBTreePy._set_type = QLSetPy
QLTreeSetPy._mapping_type = QLBucketPy
QLTreeSetPy._set_type = QLTreeSetPy._bucket_type = QLSetPy
differencePy = _set_operation(_difference, QLSetPy)
unionPy = _set_operation(_union, QLSetPy)
intersectionPy = _set_operation(_intersection, QLSetPy)
multiunionPy = _set_operation(_multiunion, QLSetPy)
weightedUnionPy = _set_operation(_weightedUnion, QLSetPy)
weightedIntersectionPy = _set_operation(_weightedIntersection, QLSetPy)
import_c_extension(globals())
_fix_pickle(globals(), __name__)
moduleProvides(IUnsignedIntegerBTreeModule)
##############################################################################
#
# Copyright (c) 2001-2012 Zope Foundation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
#
##############################################################################
__all__ = ('Bucket', 'Set', 'BTree', 'TreeSet',
'QOBucket', 'QOSet', 'QOBTree', 'QOTreeSet',
'union', 'intersection', 'difference', 'multiunion',
)
from zope.interface import moduleProvides
from .Interfaces import IUnsignedObjectBTreeModule
from ._base import Bucket
from ._base import MERGE_WEIGHT_default
from ._base import Set
from ._base import Tree as BTree
from ._base import TreeSet
from ._base import _TreeIterator
from ._base import difference as _difference
from ._base import intersection as _intersection
from ._base import multiunion as _multiunion
from ._base import set_operation as _set_operation
from ._base import to_ulong as _to_key
from ._base import to_ob as _to_value
from ._base import union as _union
from ._base import _fix_pickle
from ._compat import import_c_extension
_BUCKET_SIZE = 60
_TREE_SIZE = 500
using64bits = True
class QOBucketPy(Bucket):
_to_key = _to_key
_to_value = _to_value
MERGE_WEIGHT = MERGE_WEIGHT_default
class QOSetPy(Set):
_to_key = _to_key
class QOBTreePy(BTree):
max_leaf_size = _BUCKET_SIZE
max_internal_size = _TREE_SIZE
_to_key = _to_key
_to_value = _to_value
MERGE_WEIGHT = MERGE_WEIGHT_default
class QOTreeSetPy(TreeSet):
max_leaf_size = _BUCKET_SIZE
max_internal_size = _TREE_SIZE
_to_key = _to_key
class QOTreeIteratorPy(_TreeIterator):
pass
# Can't declare forward refs, so fix up afterwards:
QOBucketPy._mapping_type = QOBucketPy._bucket_type = QOBucketPy
QOBucketPy._set_type = QOSetPy
QOSetPy._mapping_type = QOBucketPy
QOSetPy._set_type = QOSetPy._bucket_type = QOSetPy
QOBTreePy._mapping_type = QOBTreePy._bucket_type = QOBucketPy
QOBTreePy._set_type = QOSetPy
QOTreeSetPy._mapping_type = QOBucketPy
QOTreeSetPy._set_type = QOTreeSetPy._bucket_type = QOSetPy
differencePy = _set_operation(_difference, QOSetPy)
unionPy = _set_operation(_union, QOSetPy)
intersectionPy = _set_operation(_intersection, QOSetPy)
multiunionPy = _set_operation(_multiunion, QOSetPy)
import_c_extension(globals())
_fix_pickle(globals(), __name__)
moduleProvides(IUnsignedObjectBTreeModule)
##############################################################################
#
# Copyright (c) 2001-2012 Zope Foundation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
#
##############################################################################
__all__ = ('Bucket', 'Set', 'BTree', 'TreeSet',
'QQBucket', 'QQSet', 'QQBTree', 'QQTreeSet',
'union', 'intersection', 'difference',
'weightedUnion', 'weightedIntersection', 'multiunion',
)
from zope.interface import moduleProvides
from .Interfaces import IUnsignedUnsignedBTreeModule
from ._base import Bucket
from ._base import MERGE
from ._base import MERGE_WEIGHT_numeric
from ._base import MERGE_DEFAULT_int
from ._base import Set
from ._base import Tree as BTree
from ._base import TreeSet
from ._base import _TreeIterator
from ._base import difference as _difference
from ._base import intersection as _intersection
from ._base import multiunion as _multiunion
from ._base import set_operation as _set_operation
from ._base import to_ulong as _to_key
_to_value = _to_key
from ._base import union as _union
from ._base import weightedIntersection as _weightedIntersection
from ._base import weightedUnion as _weightedUnion
from ._base import _fix_pickle
from ._compat import import_c_extension
_BUCKET_SIZE = 120
_TREE_SIZE = 500
using64bits = True
class QQBucketPy(Bucket):
_to_key = _to_key
_to_value = _to_value
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_int
class QQSetPy(Set):
_to_key = _to_key
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_int
class QQBTreePy(BTree):
max_leaf_size = _BUCKET_SIZE
max_internal_size = _TREE_SIZE
_to_key = _to_key
_to_value = _to_value
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_int
class QQTreeSetPy(TreeSet):
max_leaf_size = _BUCKET_SIZE
max_internal_size = _TREE_SIZE
_to_key = _to_key
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_int
class QQTreeIteratorPy(_TreeIterator):
pass
# Can't declare forward refs, so fix up afterwards:
QQBucketPy._mapping_type = QQBucketPy._bucket_type = QQBucketPy
QQBucketPy._set_type = QQSetPy
QQSetPy._mapping_type = QQBucketPy
QQSetPy._set_type = QQSetPy._bucket_type = QQSetPy
QQBTreePy._mapping_type = QQBTreePy._bucket_type = QQBucketPy
QQBTreePy._set_type = QQSetPy
QQTreeSetPy._mapping_type = QQBucketPy
QQTreeSetPy._set_type = QQTreeSetPy._bucket_type = QQSetPy
differencePy = _set_operation(_difference, QQSetPy)
unionPy = _set_operation(_union, QQSetPy)
intersectionPy = _set_operation(_intersection, QQSetPy)
multiunionPy = _set_operation(_multiunion, QQSetPy)
weightedUnionPy = _set_operation(_weightedUnion, QQSetPy)
weightedIntersectionPy = _set_operation(_weightedIntersection, QQSetPy)
import_c_extension(globals())
_fix_pickle(globals(), __name__)
moduleProvides(IUnsignedUnsignedBTreeModule)
##############################################################################
#
# Copyright (c) 2001-2012 Zope Foundation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
#
##############################################################################
__all__ = ('Bucket', 'Set', 'BTree', 'TreeSet',
'UFBucket', 'UFSet', 'UFBTree', 'UFTreeSet',
'union', 'intersection', 'difference',
'weightedUnion', 'weightedIntersection', 'multiunion',
)
from zope.interface import moduleProvides
from .Interfaces import IUnsignedFloatBTreeModule
from ._base import Bucket
from ._base import MERGE
from ._base import MERGE_WEIGHT_numeric
from ._base import MERGE_DEFAULT_float
from ._base import Set
from ._base import Tree as BTree
from ._base import TreeSet
from ._base import _TreeIterator
from ._base import difference as _difference
from ._base import intersection as _intersection
from ._base import multiunion as _multiunion
from ._base import set_operation as _set_operation
from ._base import to_uint as _to_key
from ._base import to_float as _to_value
from ._base import union as _union
from ._base import weightedIntersection as _weightedIntersection
from ._base import weightedUnion as _weightedUnion
from ._base import _fix_pickle
from ._compat import import_c_extension
_BUCKET_SIZE = 120
_TREE_SIZE = 500
using64bits = False
class UFBucketPy(Bucket):
_to_key = _to_key
_to_value = _to_value
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_float
class UFSetPy(Set):
_to_key = _to_key
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_float
class UFBTreePy(BTree):
max_leaf_size = _BUCKET_SIZE
max_internal_size = _TREE_SIZE
_to_key = _to_key
_to_value = _to_value
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_float
class UFTreeSetPy(TreeSet):
max_leaf_size = _BUCKET_SIZE
max_internal_size = _TREE_SIZE
_to_key = _to_key
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_float
class UFTreeIteratorPy(_TreeIterator):
pass
# Can't declare forward refs, so fix up afterwards:
UFBucketPy._mapping_type = UFBucketPy._bucket_type = UFBucketPy
UFBucketPy._set_type = UFSetPy
UFSetPy._mapping_type = UFBucketPy
UFSetPy._set_type = UFSetPy._bucket_type = UFSetPy
UFBTreePy._mapping_type = UFBTreePy._bucket_type = UFBucketPy
UFBTreePy._set_type = UFSetPy
UFTreeSetPy._mapping_type = UFBucketPy
UFTreeSetPy._set_type = UFTreeSetPy._bucket_type = UFSetPy
differencePy = _set_operation(_difference, UFSetPy)
unionPy = _set_operation(_union, UFSetPy)
intersectionPy = _set_operation(_intersection, UFSetPy)
multiunionPy = _set_operation(_multiunion, UFSetPy)
weightedUnionPy = _set_operation(_weightedUnion, UFSetPy)
weightedIntersectionPy = _set_operation(_weightedIntersection, UFSetPy)
import_c_extension(globals())
_fix_pickle(globals(), __name__)
moduleProvides(IUnsignedFloatBTreeModule)
##############################################################################
#
# Copyright (c) 2001-2012 Zope Foundation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
#
##############################################################################
__all__ = ('Bucket', 'Set', 'BTree', 'TreeSet',
'UIBucket', 'UISet', 'UIBTree', 'UITreeSet',
'union', 'intersection', 'difference',
'weightedUnion', 'weightedIntersection', 'multiunion',
)
from zope.interface import moduleProvides
from .Interfaces import IUnsignedIntegerBTreeModule
from ._base import Bucket
from ._base import MERGE
from ._base import MERGE_WEIGHT_numeric
from ._base import MERGE_DEFAULT_int
from ._base import Set
from ._base import Tree as BTree
from ._base import TreeSet
from ._base import _TreeIterator
from ._base import difference as _difference
from ._base import intersection as _intersection
from ._base import multiunion as _multiunion
from ._base import set_operation as _set_operation
from ._base import to_uint as _to_key
from ._base import to_int as _to_value
from ._base import union as _union
from ._base import weightedIntersection as _weightedIntersection
from ._base import weightedUnion as _weightedUnion
from ._base import _fix_pickle
from ._compat import import_c_extension
_BUCKET_SIZE = 120
_TREE_SIZE = 500
using64bits = False
class UIBucketPy(Bucket):
_to_key = _to_key
_to_value = _to_value
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_int
class UISetPy(Set):
_to_key = _to_key
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_int
class UIBTreePy(BTree):
max_leaf_size = _BUCKET_SIZE
max_internal_size = _TREE_SIZE
_to_key = _to_key
_to_value = _to_value
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_int
class UITreeSetPy(TreeSet):
max_leaf_size = _BUCKET_SIZE
max_internal_size = _TREE_SIZE
_to_key = _to_key
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_int
class UITreeIteratorPy(_TreeIterator):
pass
# Can't declare forward refs, so fix up afterwards:
UIBucketPy._mapping_type = UIBucketPy._bucket_type = UIBucketPy
UIBucketPy._set_type = UISetPy
UISetPy._mapping_type = UIBucketPy
UISetPy._set_type = UISetPy._bucket_type = UISetPy
UIBTreePy._mapping_type = UIBTreePy._bucket_type = UIBucketPy
UIBTreePy._set_type = UISetPy
UITreeSetPy._mapping_type = UIBucketPy
UITreeSetPy._set_type = UITreeSetPy._bucket_type = UISetPy
differencePy = _set_operation(_difference, UISetPy)
unionPy = _set_operation(_union, UISetPy)
intersectionPy = _set_operation(_intersection, UISetPy)
multiunionPy = _set_operation(_multiunion, UISetPy)
weightedUnionPy = _set_operation(_weightedUnion, UISetPy)
weightedIntersectionPy = _set_operation(_weightedIntersection, UISetPy)
import_c_extension(globals())
_fix_pickle(globals(), __name__)
moduleProvides(IUnsignedIntegerBTreeModule)
##############################################################################
#
# Copyright (c) 2001-2012 Zope Foundation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
#
##############################################################################
__all__ = ('Bucket', 'Set', 'BTree', 'TreeSet',
'UOBucket', 'UOSet', 'UOBTree', 'UOTreeSet',
'union', 'intersection', 'difference', 'multiunion',
)
from zope.interface import moduleProvides
from .Interfaces import IUnsignedObjectBTreeModule
from ._base import Bucket
from ._base import MERGE_WEIGHT_default
from ._base import Set
from ._base import Tree as BTree
from ._base import TreeSet
from ._base import _TreeIterator
from ._base import difference as _difference
from ._base import intersection as _intersection
from ._base import multiunion as _multiunion
from ._base import set_operation as _set_operation
from ._base import to_uint as _to_key
from ._base import to_ob as _to_value
from ._base import union as _union
from ._base import _fix_pickle
from ._compat import import_c_extension
_BUCKET_SIZE = 60
_TREE_SIZE = 500
using64bits = False
class UOBucketPy(Bucket):
_to_key = _to_key
_to_value = _to_value
MERGE_WEIGHT = MERGE_WEIGHT_default
class UOSetPy(Set):
_to_key = _to_key
class UOBTreePy(BTree):
max_leaf_size = _BUCKET_SIZE
max_internal_size = _TREE_SIZE
_to_key = _to_key
_to_value = _to_value
MERGE_WEIGHT = MERGE_WEIGHT_default
class UOTreeSetPy(TreeSet):
max_leaf_size = _BUCKET_SIZE
max_internal_size = _TREE_SIZE
_to_key = _to_key
class UOTreeIteratorPy(_TreeIterator):
pass
# Can't declare forward refs, so fix up afterwards:
UOBucketPy._mapping_type = UOBucketPy._bucket_type = UOBucketPy
UOBucketPy._set_type = UOSetPy
UOSetPy._mapping_type = UOBucketPy
UOSetPy._set_type = UOSetPy._bucket_type = UOSetPy
UOBTreePy._mapping_type = UOBTreePy._bucket_type = UOBucketPy
UOBTreePy._set_type = UOSetPy
UOTreeSetPy._mapping_type = UOBucketPy
UOTreeSetPy._set_type = UOTreeSetPy._bucket_type = UOSetPy
differencePy = _set_operation(_difference, UOSetPy)
unionPy = _set_operation(_union, UOSetPy)
intersectionPy = _set_operation(_intersection, UOSetPy)
multiunionPy = _set_operation(_multiunion, UOSetPy)
import_c_extension(globals())
_fix_pickle(globals(), __name__)
moduleProvides(IUnsignedObjectBTreeModule)
##############################################################################
#
# Copyright (c) 2001-2012 Zope Foundation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
#
##############################################################################
__all__ = ('Bucket', 'Set', 'BTree', 'TreeSet',
'UUBucket', 'UUSet', 'UUBTree', 'UUTreeSet',
'union', 'intersection', 'difference',
'weightedUnion', 'weightedIntersection', 'multiunion',
)
from zope.interface import moduleProvides
from .Interfaces import IUnsignedUnsignedBTreeModule
from ._base import Bucket
from ._base import MERGE
from ._base import MERGE_WEIGHT_numeric
from ._base import MERGE_DEFAULT_int
from ._base import Set
from ._base import Tree as BTree
from ._base import TreeSet
from ._base import _TreeIterator
from ._base import difference as _difference
from ._base import intersection as _intersection
from ._base import multiunion as _multiunion
from ._base import set_operation as _set_operation
from ._base import to_uint as _to_key
_to_value = _to_key
from ._base import union as _union
from ._base import weightedIntersection as _weightedIntersection
from ._base import weightedUnion as _weightedUnion
from ._base import _fix_pickle
from ._compat import import_c_extension
_BUCKET_SIZE = 120
_TREE_SIZE = 500
using64bits = False
class UUBucketPy(Bucket):
_to_key = _to_key
_to_value = _to_value
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_int
class UUSetPy(Set):
_to_key = _to_key
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_int
class UUBTreePy(BTree):
max_leaf_size = _BUCKET_SIZE
max_internal_size = _TREE_SIZE
_to_key = _to_key
_to_value = _to_value
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_int
class UUTreeSetPy(TreeSet):
max_leaf_size = _BUCKET_SIZE
max_internal_size = _TREE_SIZE
_to_key = _to_key
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_int
class UUTreeIteratorPy(_TreeIterator):
pass
# Can't declare forward refs, so fix up afterwards:
UUBucketPy._mapping_type = UUBucketPy._bucket_type = UUBucketPy
UUBucketPy._set_type = UUSetPy
UUSetPy._mapping_type = UUBucketPy
UUSetPy._set_type = UUSetPy._bucket_type = UUSetPy
UUBTreePy._mapping_type = UUBTreePy._bucket_type = UUBucketPy
UUBTreePy._set_type = UUSetPy
UUTreeSetPy._mapping_type = UUBucketPy
UUTreeSetPy._set_type = UUTreeSetPy._bucket_type = UUSetPy
differencePy = _set_operation(_difference, UUSetPy)
unionPy = _set_operation(_union, UUSetPy)
intersectionPy = _set_operation(_intersection, UUSetPy)
multiunionPy = _set_operation(_multiunion, UUSetPy)
weightedUnionPy = _set_operation(_weightedUnion, UUSetPy)
weightedIntersectionPy = _set_operation(_weightedIntersection, UUSetPy)
import_c_extension(globals())
_fix_pickle(globals(), __name__)
moduleProvides(IUnsignedUnsignedBTreeModule)
......@@ -12,15 +12,65 @@
#
#############################################################################
import sys
import zope.interface
import BTrees.Interfaces
from ._module_builder import create_module
__all__ = [
'family32',
'family64',
]
_FAMILIES = (
# Signed 32-bit keys
"IO", # object value
"II", # self value
"IF", # float value
"IU", # opposite sign value
# Unsigned 32-bit keys
"UO", # object value
"UU", # self value
"UF", # float value
"UI", # opposite sign value
# Signed 64-bit keys
"LO", # object value
"LL", # self value
"LF", # float value
"LQ", # opposite sign value
# Unsigned 64-bit keys
"QO", # object value
"QQ", # self value
"QF", # float value
"QL", # opposite sign value
# Object keys
"OO", # object
"OI", # 32-bit signed
"OU", # 32-bit unsigned
"OL", # 64-bit signed
"OQ", # 64-bit unsigned
)
# XXX: Do this without completely ruining
# pylint and other static analysis.
for family in _FAMILIES:
mod = create_module(family)
name = vars(mod)['__name__']
sys.modules[name] = mod
globals()[name.split('.', 1)[1]] = mod
__all__.append(name)
@zope.interface.implementer(BTrees.Interfaces.IBTreeFamily)
class _Family(object):
from BTrees import OOBTree as OO
_BITSIZE = 0
minint = maxint = maxuint = 0
minint = maxint = maxuint = None
def __init__(self):
self.maxint = int(2 ** (self._BITSIZE - 1) - 1)
self.minint = int(-self.maxint - 1)
self.maxuint = int(2 ** self._BITSIZE - 1)
def __str__(self):
return (
......@@ -49,10 +99,6 @@ class _Family32(_Family):
from BTrees import UOBTree as UO
from BTrees import UUBTree as UU
maxuint = int(2**32)
maxint = int(2**31-1)
minint = -maxint - 1
def __reduce__(self):
return _family32, ()
......@@ -71,10 +117,6 @@ class _Family64(_Family):
from BTrees import QOBTree as UO
from BTrees import QQBTree as UU
maxuint = 2**64
maxint = 2**63-1
minint = -maxint - 1
def __reduce__(self):
return _family64, ()
......
......@@ -14,18 +14,24 @@
"""Python BTree implementation
"""
from struct import Struct
from struct import error as struct_error
from operator import index
from persistent import Persistent
from .Interfaces import BTreesConflictError
from ._compat import PY3
from ._compat import compare
from ._compat import int_types
from ._compat import xrange
# XXX: Fix these. These ignores are temporary to
# reduce the noise and help find specific issues during
# refactoring
# pylint:disable=too-many-lines,fixme,protected-access
# pylint:disable=attribute-defined-outside-init,redefined-builtin,no-else-return
# pylint:disable=redefined-outer-name,bad-continuation,unused-variable
# pylint:disable=too-many-branches,too-many-statements,arguments-differ,assigning-non-slot
# pylint:disable=superfluous-parens,inconsistent-return-statements,unidiomatic-typecheck
# pylint:disable=deprecated-method,consider-using-enumerate
_marker = object()
......@@ -33,6 +39,11 @@ _marker = object()
class _Base(Persistent):
__slots__ = ()
# This is used to allocate storage for the keys.
# It's probably here so that we could, for example, use
# an ``array.array`` for native types. But nothing actually does
# that, everything is stored boxed.
# TODO: Figure out why not.
_key_type = list
def __init__(self, items=None):
......@@ -190,7 +201,13 @@ class _BucketBase(_Base):
return iter(self._keys)
def __contains__(self, key):
return (self._search(self._to_key(key)) >= 0)
try:
tree_key = self._to_key(key)
except TypeError:
# Can't convert the key, so can't possibly be in the tree
return False
return (self._search(tree_key) >= 0)
has_key = __contains__
......@@ -252,25 +269,6 @@ class _SetIteration(object):
return self
_object_lt = getattr(object, '__lt__', _marker)
def _no_default_comparison(key):
# Enforce test that key has non-default comparison.
if key is None:
return
if type(key) is object:
raise TypeError("Can't use object() as keys")
lt = getattr(key, '__lt__', None)
if lt is not None:
# CPython 3.x follows PEP 252, defining '__objclass__'
if getattr(lt, '__objclass__', None) is object:
lt = None # pragma: no cover Py3k
# PyPy3 doesn't follow PEP 252, but defines '__func__'
elif getattr(lt, '__func__', None) is _object_lt:
lt = None # pragma: no cover PyPy3
if (lt is None and
getattr(key, '__cmp__', None) is None):
raise TypeError("Object has default comparison")
class Bucket(_BucketBase):
......@@ -308,7 +306,6 @@ class Bucket(_BucketBase):
raise TypeError('items must be a sequence of 2-tuples')
def __setitem__(self, key, value):
_no_default_comparison(key)
self._set(self._to_key(key), self._to_value(value))
def __delitem__(self, key):
......@@ -319,13 +316,23 @@ class Bucket(_BucketBase):
self._values = self._value_type()
def get(self, key, default=None):
index = self._search(self._to_key(key))
try:
key = self._to_key(key)
except TypeError:
# Can't convert, cannot possibly be present.
return default
index = self._search(key)
if index < 0:
return default
return self._values[index]
def __getitem__(self, key):
index = self._search(self._to_key(key))
try:
tree_key = self._to_key(key)
except TypeError:
# Can't convert, so cannot possibly be present.
raise KeyError(key)
index = self._search(tree_key)
if index < 0:
raise KeyError(key)
return self._values[index]
......@@ -809,7 +816,6 @@ class _Tree(_Base):
set(*i)
def __setitem__(self, key, value):
_no_default_comparison(key)
self._set(self._to_key(key), self._to_value(value))
def __delitem__(self, key):
......@@ -990,7 +996,7 @@ class _Tree(_Base):
if isinstance(first.child, type(self)):
next._firstbucket = first.child._firstbucket
else:
next._firstbucket = first.child;
next._firstbucket = first.child
return next
def _del(self, key):
......@@ -1111,7 +1117,7 @@ class _Tree(_Base):
"BTree has firstbucket different than "
"its first child's firstbucket")
for i in range(len(data)-1):
data[i].child._check(data[i+1].child._firstbucket)
data[i].child._check(data[i+1].child._firstbucket)
data[-1].child._check(nextbucket)
elif child_class is self._bucket_type:
assert_(self._firstbucket is data[0].child,
......@@ -1297,13 +1303,23 @@ class TreeSet(_Tree):
class set_operation(object):
__slots__ = ('func',
'set_type',
)
__slots__ = (
'func',
'set_type',
'__name__',
'_module',
)
def __init__(self, func, set_type):
self.func = func
self.set_type = set_type
self.__name__ = func.__name__
self._module = func.__module__
__module__ = property(
lambda self: self._module,
lambda self, nv: setattr(self, '_module', nv)
)
def __call__(self, *a, **k):
return self.func(self.set_type, *a, **k)
......@@ -1492,83 +1508,6 @@ def multiunion(set_type, seqs):
result.update(s)
return result
def to_ob(self, v):
return v
def _packer_unpacker(struct_format):
s = Struct(struct_format)
return s.pack, s.unpack
int_pack, int_unpack = _packer_unpacker('i')
def to_int(self, v):
try:
int_pack(index(v))
except (struct_error, TypeError):
raise TypeError('32-bit integer expected')
return int(v)
# PyPy can raise ValueError converting a negative number to a
# unsigned value.
uint_pack, uint_unpack = _packer_unpacker('I')
def to_uint(self, v):
try:
uint_pack(index(v))
except (struct_error, TypeError, ValueError):
if isinstance(v, int_types):
raise OverflowError("Value out of range", v)
raise TypeError('non-negative 32-bit integer expected')
return int(v)
float_pack = _packer_unpacker('f')[0]
def to_float(self, v):
try:
float_pack(v)
except struct_error:
raise TypeError('float expected')
return float(v)
long_pack, long_unpack = _packer_unpacker('q')
def to_long(self, v):
try:
long_pack(index(v))
except (struct_error, TypeError):
if isinstance(v, int_types):
raise OverflowError("Value out of range", v)
raise TypeError('64-bit integer expected')
return int(v)
ulong_pack, ulong_unpack = _packer_unpacker('Q')
def to_ulong(self, v):
try:
ulong_pack(index(v))
except (struct_error, TypeError, ValueError):
if isinstance(v, int_types):
raise OverflowError("Value out of range", v)
raise TypeError('non-negative 64-bit integer expected')
return int(v)
def to_bytes(l):
def to(self, v):
if not (isinstance(v, bytes) and len(v) == l):
raise TypeError("%s-byte array expected" % l)
return v
return to
tos = dict(I=to_int, L=to_long, F=to_float, O=to_ob, U=to_uint, Q=to_ulong)
MERGE_DEFAULT_int = 1
MERGE_DEFAULT_float = 1.0
def MERGE(self, value1, weight1, value2, weight2):
return (value1 * weight1) + (value2 * weight2)
......
......@@ -97,4 +97,4 @@ def import_c_extension(mod_globals):
mod_globals[name] = mod_globals[prefix + name]
# Cleanup
del mod_globals['import_c_extension']
mod_globals.pop('import_c_extension', None)
This diff is collapsed.
##############################################################################
#
# Copyright Zope Foundation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""
Support functions to eliminate the boilerplate involved in defining
BTree modules.
"""
import sys
from zope.interface import directlyProvides
def _create_classes(
module_name, key_datatype, value_datatype,
):
from ._base import Bucket
from ._base import MERGE # Won't always want this.
from ._base import Set
from ._base import Tree
from ._base import TreeSet
from ._base import _TreeIterator
from ._base import _fix_pickle
classes = {}
prefix = key_datatype.prefix_code + value_datatype.prefix_code
for base in (
Bucket,
Set,
(Tree, 'BTree'),
TreeSet,
(_TreeIterator, 'TreeIterator'),
):
if isinstance(base, tuple):
base, base_name = base
else:
base_name = base.__name__
# XXX: Consider defining these with their natural names
# now and only aliasing them to 'Py' instead of the
# opposite. That should make pickling easier.
name = prefix + base_name + 'Py'
cls = type(name, (base,), dict(
_to_key=key_datatype,
_to_value=value_datatype,
MERGE=MERGE,
MERGE_WEIGHT=value_datatype.apply_weight,
MERGE_DEFAULT=value_datatype.multiplication_identity,
max_leaf_size=key_datatype.bucket_size_for_value(value_datatype),
max_internal_size=key_datatype.tree_size,
))
cls.__module__ = module_name
classes[cls.__name__] = cls
# Importing the C extension does this for the non-py
# classes.
# TODO: Unify that.
classes[base_name + 'Py'] = cls
for cls in classes.values():
cls._mapping_type = classes['BucketPy']
cls._set_type = classes['SetPy']
if 'Set' in cls.__name__:
cls._bucket_type = classes['SetPy']
else:
cls._bucket_type = classes['BucketPy']
return classes
def _create_set_operations(module_name, key_type, value_type, set_type):
from ._base import set_operation
from ._base import difference
from ._base import intersection
from ._base import multiunion
from ._base import union
from ._base import weightedIntersection
from ._base import weightedUnion
ops = {
op.__name__ + 'Py': set_operation(op, set_type)
for op in (
difference, intersection,
union,
) + (
(weightedIntersection, weightedUnion,)
if value_type.supports_value_union()
else ()
) + (
(multiunion,)
if key_type.supports_value_union()
else ()
)
}
for key, op in ops.items():
op.__module__ = module_name
op.__name__ = key
# TODO: Pickling. These things should be looked up by name.
return ops
def _create_globals(module_name, key_datatype, value_datatype):
classes = _create_classes(module_name, key_datatype, value_datatype)
set_type = classes['SetPy']
set_ops = _create_set_operations(module_name, key_datatype, value_datatype, set_type)
classes.update(set_ops)
return classes
def populate_module(mod_globals,
key_datatype, value_datatype,
interface, module=None):
from ._compat import import_c_extension
from ._base import _fix_pickle
module_name = mod_globals['__name__']
mod_globals.update(_create_globals(module_name, key_datatype, value_datatype))
# XXX: Maybe derive this from the values we create.
mod_all = (
'Bucket', 'Set', 'BTree', 'TreeSet',
'union', 'intersection', 'difference',
'weightedUnion', 'weightedIntersection', 'multiunion',
)
prefix = key_datatype.prefix_code + value_datatype.prefix_code
mod_all += tuple(prefix + c for c in ('Bucket', 'Set', 'BTree', 'TreeSet'))
mod_globals['__all__'] = tuple(c for c in mod_all if c in mod_globals)
mod_globals['using64bits'] = key_datatype.using64bits or value_datatype.using64bits
import_c_extension(mod_globals)
# XXX: We can probably do better than fix_pickle now;
# we can know if we're going to be renaming classes
# ahead of time.
_fix_pickle(mod_globals, module_name)
directlyProvides(module or sys.modules[module_name], interface)
def create_module(prefix):
import types
from . import _datatypes as datatypes
from . import Interfaces
mod = types.ModuleType('BTrees.' + prefix + 'BTree')
key_type = getattr(datatypes, prefix[0])()
val_type = getattr(datatypes, prefix[1])().as_value_type()
iface_name = 'I' + key_type.long_name + val_type.long_name + 'BTreeModule'
iface = getattr(Interfaces, iface_name)
populate_module(vars(mod), key_type, val_type, iface, mod)
return mod
......@@ -32,19 +32,19 @@ from ._base import TreeSet
from ._base import difference as _difference
from ._base import intersection as _intersection
from ._base import set_operation as _set_operation
from ._base import to_bytes as _to_bytes
from ._base import union as _union
from ._base import _fix_pickle
from ._compat import import_c_extension
from ._datatypes import Bytes
_BUCKET_SIZE = 500
_TREE_SIZE = 500
using64bits = False
_to_key = _to_bytes(2)
_to_value = _to_bytes(6)
_to_key = Bytes(2)
_to_value = Bytes(6)
# XXX: Port this to use _module_builder.
class fsBucketPy(Bucket):
_to_key = _to_key
_to_value = _to_value
......
......@@ -25,7 +25,7 @@
long vcopy = INT_AS_LONG(ARG); \
if (PyErr_Occurred()) { (STATUS)=0; (TARGET)=0; } \
else if ((int)vcopy != vcopy) { \
PyErr_SetString(PyExc_TypeError, "integer out of range"); \
PyErr_SetString(PyExc_OverflowError, "integer out of range"); \
(STATUS)=0; (TARGET)=0; \
} \
else TARGET = vcopy; \
......@@ -61,7 +61,7 @@
(STATUS)=0; (TARGET)=0; \
} \
else if ((unsigned int)vcopy != vcopy) { \
PyErr_SetString(PyExc_TypeError, "integer out of range"); \
PyErr_SetString(PyExc_OverflowError, "integer out of range"); \
(STATUS)=0; (TARGET)=0; \
} \
else TARGET = vcopy; \
......
......@@ -31,7 +31,7 @@
long vcopy = INT_AS_LONG(ARG); \
if (PyErr_Occurred()) { (STATUS)=0; (TARGET)=0; } \
else if ((int)vcopy != vcopy) { \
PyErr_SetString(PyExc_TypeError, "integer out of range"); \
PyErr_SetString(PyExc_OverflowError, "integer out of range"); \
(STATUS)=0; (TARGET)=0; \
} \
else TARGET = vcopy; \
......@@ -68,7 +68,7 @@
(STATUS)=0; (TARGET)=0; \
} \
else if ((unsigned int)vcopy != vcopy) { \
PyErr_SetString(PyExc_TypeError, "integer out of range"); \
PyErr_SetString(PyExc_OverflowError, "integer out of range"); \
(STATUS)=0; (TARGET)=0; \
} \
else TARGET = vcopy; \
......
# If tests is a package, debugging is a bit easier.
# Make this a package.
This diff is collapsed.
This diff is collapsed.
##############################################################################
#
# Copyright (c) 2001-2012 Zope Foundation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
#
##############################################################################
import unittest
from .common import BTreeTests
from .common import ExtendedSetTests
from .common import InternalKeysMappingTest
from .common import MappingBase
from .common import MappingConflictTestBase
from .common import ModuleTest
from .common import MultiUnion
from .common import NormalSetTests
from .common import SetConflictTestBase
from .common import SetResult
from .common import makeBuilder
class IFBTreeInternalKeyTest(InternalKeysMappingTest, unittest.TestCase):
def _getTargetClass(self):
from BTrees.IFBTree import IFBTree
return IFBTree
class IFBTreePyInternalKeyTest(InternalKeysMappingTest, unittest.TestCase):
def _getTargetClass(self):
from BTrees.IFBTree import IFBTreePy
return IFBTreePy
class IFBucketTest(MappingBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.IFBTree import IFBucket
return IFBucket
class IFBucketPyTest(MappingBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.IFBTree import IFBucketPy
return IFBucketPy
class IFTreeSetTest(NormalSetTests, unittest.TestCase):
def _getTargetClass(self):
from BTrees.IFBTree import IFTreeSet
return IFTreeSet
class IFTreeSetPyTest(NormalSetTests, unittest.TestCase):
def _getTargetClass(self):
from BTrees.IFBTree import IFTreeSetPy
return IFTreeSetPy
class IFSetTest(ExtendedSetTests, unittest.TestCase):
def _getTargetClass(self):
from BTrees.IFBTree import IFSet
return IFSet
class IFSetPyTest(ExtendedSetTests, unittest.TestCase):
def _getTargetClass(self):
from BTrees.IFBTree import IFSetPy
return IFSetPy
class IFBTreeTest(BTreeTests, unittest.TestCase):
def _makeOne(self):
from BTrees.IFBTree import IFBTree
return IFBTree()
class IFBTreePyTest(BTreeTests, unittest.TestCase):
def _makeOne(self):
from BTrees.IFBTree import IFBTreePy
return IFBTreePy()
class _TestIFBTreesBase(object):
def testNonIntegerKeyRaises(self):
self.assertRaises(TypeError, self._stringraiseskey)
self.assertRaises(TypeError, self._floatraiseskey)
self.assertRaises(TypeError, self._noneraiseskey)
def testNonNumericValueRaises(self):
self.assertRaises(TypeError, self._stringraisesvalue)
self.assertRaises(TypeError, self._noneraisesvalue)
self._makeOne()[1] = 1
self._makeOne()[1] = 1.0
def _stringraiseskey(self):
self._makeOne()['c'] = 1
def _floatraiseskey(self):
self._makeOne()[2.5] = 1
def _noneraiseskey(self):
self._makeOne()[None] = 1
def _stringraisesvalue(self):
self._makeOne()[1] = 'c'
def _floatraisesvalue(self):
self._makeOne()[1] = 1.4
def _noneraisesvalue(self):
self._makeOne()[1] = None
class TestIFBTrees(_TestIFBTreesBase, unittest.TestCase):
def _makeOne(self):
from BTrees.IFBTree import IFBTree
return IFBTree()
class TestIFBTreesPy(_TestIFBTreesBase, unittest.TestCase):
def _makeOne(self):
from BTrees.IFBTree import IFBTreePy
return IFBTreePy()
class TestIFMultiUnion(MultiUnion, unittest.TestCase):
def multiunion(self, *args):
from BTrees.IFBTree import multiunion
return multiunion(*args)
def union(self, *args):
from BTrees.IFBTree import union
return union(*args)
def mkset(self, *args):
from BTrees.IFBTree import IFSet as mkset
return mkset(*args)
def mktreeset(self, *args):
from BTrees.IFBTree import IFTreeSet as mktreeset
return mktreeset(*args)
def mkbucket(self, *args):
from BTrees.IFBTree import IFBucket as mkbucket
return mkbucket(*args)
def mkbtree(self, *args):
from BTrees.IFBTree import IFBTree as mkbtree
return mkbtree(*args)
class TestIFMultiUnionPy(MultiUnion, unittest.TestCase):
def multiunion(self, *args):
from BTrees.IFBTree import multiunionPy
return multiunionPy(*args)
def union(self, *args):
from BTrees.IFBTree import unionPy
return unionPy(*args)
def mkset(self, *args):
from BTrees.IFBTree import IFSetPy as mkset
return mkset(*args)
def mktreeset(self, *args):
from BTrees.IFBTree import IFTreeSetPy as mktreeset
return mktreeset(*args)
def mkbucket(self, *args):
from BTrees.IFBTree import IFBucketPy as mkbucket
return mkbucket(*args)
def mkbtree(self, *args):
from BTrees.IFBTree import IFBTreePy as mkbtree
return mkbtree(*args)
class PureIF(SetResult, unittest.TestCase):
def union(self, *args):
from BTrees.IFBTree import union
return union(*args)
def intersection(self, *args):
from BTrees.IFBTree import intersection
return intersection(*args)
def difference(self, *args):
from BTrees.IFBTree import difference
return difference(*args)
def builders(self):
from BTrees.IFBTree import IFBTree
from BTrees.IFBTree import IFBucket
from BTrees.IFBTree import IFTreeSet
from BTrees.IFBTree import IFSet
return IFSet, IFTreeSet, makeBuilder(IFBTree), makeBuilder(IFBucket)
class PureIFPy(SetResult, unittest.TestCase):
def union(self, *args):
from BTrees.IFBTree import unionPy
return unionPy(*args)
def intersection(self, *args):
from BTrees.IFBTree import intersectionPy
return intersectionPy(*args)
def difference(self, *args):
from BTrees.IFBTree import differencePy
return differencePy(*args)
def builders(self):
from BTrees.IFBTree import IFBTreePy
from BTrees.IFBTree import IFBucketPy
from BTrees.IFBTree import IFTreeSetPy
from BTrees.IFBTree import IFSetPy
return (IFSetPy, IFTreeSetPy,
makeBuilder(IFBTreePy), makeBuilder(IFBucketPy))
class IFBTreeConflictTests(MappingConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.IFBTree import IFBTree
return IFBTree
class IFBTreePyConflictTests(MappingConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.IFBTree import IFBTreePy
return IFBTreePy
class IFBucketConflictTests(MappingConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.IFBTree import IFBucket
return IFBucket
class IFBucketPyConflictTests(MappingConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.IFBTree import IFBucketPy
return IFBucketPy
class IFTreeSetConflictTests(SetConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.IFBTree import IFTreeSet
return IFTreeSet
class IFTreeSetPyConflictTests(SetConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.IFBTree import IFTreeSetPy
return IFTreeSetPy
class IFSetConflictTests(SetConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.IFBTree import IFSet
return IFSet
class IFSetPyConflictTests(SetConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.IFBTree import IFSetPy
return IFSetPy
class IFModuleTest(ModuleTest, unittest.TestCase):
prefix = 'IF'
def _getModule(self):
import BTrees
return BTrees.IFBTree
def _getInterface(self):
import BTrees.Interfaces
return BTrees.Interfaces.IIntegerFloatBTreeModule
This diff is collapsed.
##############################################################################
#
# Copyright (c) 2001-2012 Zope Foundation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
#
##############################################################################
import unittest
from .common import BTreeTests
from .common import ExtendedSetTests
from .common import I_SetsBase
from .common import InternalKeysMappingTest
from .common import MappingBase
from .common import MappingConflictTestBase
from .common import ModuleTest
from .common import MultiUnion
from .common import NormalSetTests
from .common import SetConflictTestBase
from .common import SetResult
from .common import TypeTest
from .common import makeBuilder
class IOBTreeInternalKeyTest(InternalKeysMappingTest, unittest.TestCase):
def _getTargetClass(self):
from BTrees.IOBTree import IOBTree
return IOBTree
class IOBTreePyInternalKeyTest(InternalKeysMappingTest, unittest.TestCase):
def _getTargetClass(self):
from BTrees.IOBTree import IOBTreePy
return IOBTreePy
class IOBucketTest(MappingBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.IOBTree import IOBucket
return IOBucket
class IOBucketPyTest(MappingBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.IOBTree import IOBucketPy
return IOBucketPy
class IOTreeSetTest(NormalSetTests, unittest.TestCase):
def _getTargetClass(self):
from BTrees.IOBTree import IOTreeSet
return IOTreeSet
class IOTreeSetPyTest(NormalSetTests, unittest.TestCase):
def _getTargetClass(self):
from BTrees.IOBTree import IOTreeSetPy
return IOTreeSetPy
class IOSetTest(ExtendedSetTests, unittest.TestCase):
def _getTargetClass(self):
from BTrees.IOBTree import IOSet
return IOSet
class IOSetPyTest(ExtendedSetTests, unittest.TestCase):
def _getTargetClass(self):
from BTrees.IOBTree import IOSetPy
return IOSetPy
class IOBTreeTest(BTreeTests, unittest.TestCase):
def _makeOne(self):
from BTrees.IOBTree import IOBTree
return IOBTree()
class IOBTreePyTest(BTreeTests, unittest.TestCase):
def _makeOne(self):
from BTrees.IOBTree import IOBTreePy
return IOBTreePy()
class _TestIOBTreesBase(TypeTest):
def _stringraises(self):
self._makeOne()['c'] = 1
def _floatraises(self):
self._makeOne()[2.5] = 1
def _noneraises(self):
self._makeOne()[None] = 1
def testStringAllowedInContains(self):
self.assertFalse('key' in self._makeOne())
def testStringKeyRaisesKeyErrorWhenMissing(self):
self.assertRaises(KeyError, self._makeOne().__getitem__, 'key')
def testStringKeyReturnsDefaultFromGetWhenMissing(self):
self.assertEqual(self._makeOne().get('key', 42), 42)
class TestIOBTrees(_TestIOBTreesBase, unittest.TestCase):
def _makeOne(self):
from BTrees.IOBTree import IOBTree
return IOBTree()
class TestIOBTreesPy(_TestIOBTreesBase, unittest.TestCase):
def _makeOne(self):
from BTrees.IOBTree import IOBTreePy
return IOBTreePy()
class TestIOSets(I_SetsBase, unittest.TestCase):
def _makeOne(self):
from BTrees.IOBTree import IOSet
return IOSet()
class TestIOSetsPy(I_SetsBase, unittest.TestCase):
def _makeOne(self):
from BTrees.IOBTree import IOSetPy
return IOSetPy()
class TestIOTreeSets(I_SetsBase, unittest.TestCase):
def _makeOne(self):
from BTrees.IOBTree import IOTreeSet
return IOTreeSet()
class TestIOTreeSetsPy(I_SetsBase, unittest.TestCase):
def _makeOne(self):
from BTrees.IOBTree import IOTreeSetPy
return IOTreeSetPy()
class PureIO(SetResult, unittest.TestCase):
def union(self, *args):
from BTrees.IOBTree import union
return union(*args)
def intersection(self, *args):
from BTrees.IOBTree import intersection
return intersection(*args)
def difference(self, *args):
from BTrees.IOBTree import difference
return difference(*args)
def builders(self):
from BTrees.IOBTree import IOBTree
from BTrees.IOBTree import IOBucket
from BTrees.IOBTree import IOTreeSet
from BTrees.IOBTree import IOSet
return IOSet, IOTreeSet, makeBuilder(IOBTree), makeBuilder(IOBucket)
class PureIOPy(SetResult, unittest.TestCase):
def union(self, *args):
from BTrees.IOBTree import unionPy
return unionPy(*args)
def intersection(self, *args):
from BTrees.IOBTree import intersectionPy
return intersectionPy(*args)
def difference(self, *args):
from BTrees.IOBTree import differencePy
return differencePy(*args)
def builders(self):
from BTrees.IOBTree import IOBTreePy
from BTrees.IOBTree import IOBucketPy
from BTrees.IOBTree import IOTreeSetPy
from BTrees.IOBTree import IOSetPy
return (IOSetPy, IOTreeSetPy,
makeBuilder(IOBTreePy), makeBuilder(IOBucketPy))
class TestIOMultiUnion(MultiUnion, unittest.TestCase):
def multiunion(self, *args):
from BTrees.IOBTree import multiunion
return multiunion(*args)
def union(self, *args):
from BTrees.IOBTree import union
return union(*args)
def mkset(self, *args):
from BTrees.IOBTree import IOSet as mkset
return mkset(*args)
def mktreeset(self, *args):
from BTrees.IOBTree import IOTreeSet as mktreeset
return mktreeset(*args)
def mkbucket(self, *args):
from BTrees.IOBTree import IOBucket as mkbucket
return mkbucket(*args)
def mkbtree(self, *args):
from BTrees.IOBTree import IOBTree as mkbtree
return mkbtree(*args)
class TestIOMultiUnionPy(MultiUnion, unittest.TestCase):
def multiunion(self, *args):
from BTrees.IOBTree import multiunionPy
return multiunionPy(*args)
def union(self, *args):
from BTrees.IOBTree import unionPy
return unionPy(*args)
def mkset(self, *args):
from BTrees.IOBTree import IOSetPy as mkset
return mkset(*args)
def mktreeset(self, *args):
from BTrees.IOBTree import IOTreeSetPy as mktreeset
return mktreeset(*args)
def mkbucket(self, *args):
from BTrees.IOBTree import IOBucketPy as mkbucket
return mkbucket(*args)
def mkbtree(self, *args):
from BTrees.IOBTree import IOBTreePy as mkbtree
return mkbtree(*args)
class IOBTreeConflictTests(MappingConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.IOBTree import IOBTree
return IOBTree
class IOBTreeConflictTestsPy(MappingConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.IOBTree import IOBTreePy
return IOBTreePy
class IOBucketConflictTests(MappingConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.IOBTree import IOBucket
return IOBucket
class IOBucketConflictTestsPy(MappingConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.IOBTree import IOBucketPy
return IOBucketPy
class IOTreeSetConflictTests(SetConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.IOBTree import IOTreeSet
return IOTreeSet
class IOTreeSetConflictTestsPy(SetConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.IOBTree import IOTreeSetPy
return IOTreeSetPy
class IOSetConflictTests(SetConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.IOBTree import IOSet
return IOSet
class IOSetConflictTestsPy(SetConflictTestBase, unittest.TestCase):
def _getTargetClass(self):
from BTrees.IOBTree import IOSetPy
return IOSetPy
class IOModuleTest(ModuleTest, unittest.TestCase):
prefix = 'IO'
def _getModule(self):
import BTrees
return BTrees.IOBTree
def _getInterface(self):
import BTrees.Interfaces
return BTrees.Interfaces.IIntegerObjectBTreeModule
def test_weightedUnion_not_present(self):
try:
from BTrees.IOBTree import weightedUnion
except ImportError:
pass
else:
self.fail("IOBTree shouldn't have weightedUnion")
def test_weightedIntersection_not_present(self):
try:
from BTrees.IOBTree import weightedIntersection
except ImportError:
pass
else:
self.fail("IOBTree shouldn't have weightedIntersection")
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -405,9 +405,9 @@ class Test_check(unittest.TestCase):
def _makeTree(fill):
from BTrees.OOBTree import OOBTree
from BTrees.OOBTree import _BUCKET_SIZE
from BTrees.OOBTree import OOBTreePy
tree = OOBTree()
if fill:
for i in range(_BUCKET_SIZE + 1):
for i in range(OOBTreePy.max_leaf_size + 1):
tree[i] = 2*i
return tree
This diff is collapsed.
......@@ -43,3 +43,23 @@ def oid_repr(oid):
return b''.join(chunks)
else:
return repr(oid)
class Lazy(object):
"""
A simple version of ``Lazy`` from ``zope.cachedescriptors``
"""
__slots__ = ('func',)
def __init__(self, func):
self.func = func
def __get__(self, inst, class_):
if inst is None:
return self
func = self.func
value = func(inst)
inst.__dict__[func.__name__] = value
return value
......@@ -18,6 +18,10 @@
64-bit variants.
- Make the Bucket types consistent with the BTree types as updated in
versions 4.3.2: Querying for keys with default comparisons or that
are not integers no longer raises ``TypeError``.
4.6.1 (2019-11-07)
==================
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment