[Python-modules-commits] [python-btrees] 01/04: import python-btrees_4.3.1.orig.tar.gz

Julien Muchembled jmuchemb-guest at moszumanska.debian.org
Wed Dec 21 13:37:29 UTC 2016


This is an automated email from the git hooks/post-receive script.

jmuchemb-guest pushed a commit to branch master
in repository python-btrees.

commit 9313ee685283a034ea8c974fceec242f93a97ee4
Author: Julien Muchembled <jm at jmuchemb.eu>
Date:   Mon Dec 5 13:22:38 2016 +0100

    import python-btrees_4.3.1.orig.tar.gz
---
 .coveragerc                          |    4 +
 .gitignore                           |   19 +
 .travis.yml                          |   47 +
 BTrees.egg-info/PKG-INFO             |  245 +++
 BTrees.egg-info/SOURCES.txt          |   92 +
 BTrees.egg-info/dependency_links.txt |    1 +
 BTrees.egg-info/entry_points.txt     |    1 +
 BTrees.egg-info/not-zip-safe         |    1 +
 BTrees.egg-info/requires.txt         |   21 +
 BTrees.egg-info/top_level.txt        |    1 +
 BTrees/BTreeItemsTemplate.c          |  790 +++++++++
 BTrees/BTreeModuleTemplate.c         |  661 ++++++++
 BTrees/BTreeTemplate.c               | 2445 +++++++++++++++++++++++++++
 BTrees/BucketTemplate.c              | 1951 +++++++++++++++++++++
 BTrees/Development.txt               |  425 +++++
 BTrees/IFBTree.py                    |  140 ++
 BTrees/IIBTree.py                    |  141 ++
 BTrees/IOBTree.py                    |  119 ++
 BTrees/Interfaces.py                 |  527 ++++++
 BTrees/LFBTree.py                    |  141 ++
 BTrees/LLBTree.py                    |  141 ++
 BTrees/LOBTree.py                    |  120 ++
 BTrees/Length.py                     |   55 +
 BTrees/MergeTemplate.c               |  349 ++++
 BTrees/OIBTree.py                    |  137 ++
 BTrees/OLBTree.py                    |  137 ++
 BTrees/OOBTree.py                    |  115 ++
 BTrees/SetOpTemplate.c               |  557 ++++++
 BTrees/SetTemplate.c                 |  381 +++++
 BTrees/TreeSetTemplate.c             |  254 +++
 BTrees/_IFBTree.c                    |   41 +
 BTrees/_IIBTree.c                    |   41 +
 BTrees/_IOBTree.c                    |   39 +
 BTrees/_LFBTree.c                    |   43 +
 BTrees/_LLBTree.c                    |   43 +
 BTrees/_LOBTree.c                    |   41 +
 BTrees/_OIBTree.c                    |   39 +
 BTrees/_OLBTree.c                    |   41 +
 BTrees/_OOBTree.c                    |   39 +
 BTrees/__init__.py                   |   69 +
 BTrees/_base.py                      | 1588 +++++++++++++++++
 BTrees/_compat.h                     |   52 +
 BTrees/_compat.py                    |   56 +
 BTrees/_fsBTree.c                    |  164 ++
 BTrees/check.py                      |  424 +++++
 BTrees/floatvaluemacros.h            |   25 +
 BTrees/fsBTree.py                    |  129 ++
 BTrees/intkeymacros.h                |   40 +
 BTrees/intvaluemacros.h              |   46 +
 BTrees/nosetests.xml                 |    3 +
 BTrees/objectkeymacros.h             |   40 +
 BTrees/objectvaluemacros.h           |   12 +
 BTrees/sorters.c                     |  542 ++++++
 BTrees/tests/__init__.py             |    1 +
 BTrees/tests/common.py               | 2540 ++++++++++++++++++++++++++++
 BTrees/tests/testBTrees.py           |  539 ++++++
 BTrees/tests/testBTreesUnicode.py    |   78 +
 BTrees/tests/testConflict.py         |  573 +++++++
 BTrees/tests/test_IFBTree.py         |  378 +++++
 BTrees/tests/test_IIBTree.py         |  507 ++++++
 BTrees/tests/test_IOBTree.py         |  406 +++++
 BTrees/tests/test_LFBTree.py         |  316 ++++
 BTrees/tests/test_LLBTree.py         |  415 +++++
 BTrees/tests/test_LOBTree.py         |  359 ++++
 BTrees/tests/test_Length.py          |  110 ++
 BTrees/tests/test_OIBTree.py         |  383 +++++
 BTrees/tests/test_OLBTree.py         |  348 ++++
 BTrees/tests/test_OOBTree.py         |  324 ++++
 BTrees/tests/test__base.py           | 3086 ++++++++++++++++++++++++++++++++++
 BTrees/tests/test_btreesubclass.py   |   54 +
 BTrees/tests/test_check.py           |  425 +++++
 BTrees/tests/test_fsBTree.py         |   64 +
 BTrees/tests/test_utils.py           |   83 +
 BTrees/utils.py                      |   45 +
 CHANGES.rst                          |  201 +++
 COPYRIGHT.txt                        |    1 +
 LICENSE.txt                          |   44 +
 MANIFEST.in                          |   18 +
 PKG-INFO                             |  245 +++
 README.rst                           |   16 +
 appveyor.yml                         |   40 +
 bootstrap.py                         |  210 +++
 buildout.cfg                         |   41 +
 docs/Makefile                        |  153 ++
 docs/_static/placeholder.txt         |    0
 docs/_templates/placeholder.txt      |    0
 docs/api.rst                         |   98 ++
 docs/conf.py                         |  253 +++
 docs/index.rst                       |  462 +++++
 docs/make.bat                        |  190 +++
 setup.cfg                            |   18 +
 setup.py                             |  159 ++
 tox.ini                              |   69 +
 93 files changed, 26827 insertions(+)

diff --git a/.coveragerc b/.coveragerc
new file mode 100644
index 0000000..58d9a3a
--- /dev/null
+++ b/.coveragerc
@@ -0,0 +1,4 @@
+[report]
+exclude_lines =
+    # pragma: no cover
+    class I[A-Z]\w+\((Interface|I[A-Z].*)\):
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..e80d19d
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,19 @@
+bin
+eggs
+develop-eggs
+parts
+.installed.cfg
+build
+docs/_build
+__pycache__
+*.pyc
+*.so
+.tox
+.coverage
+nosetests.xml
+coverage.xml
+*.egg-info
+*.egg
+dist
+.eggs/
+.dir-locals.el
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..4d58671
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,47 @@
+language: python
+sudo: false
+matrix:
+    include:
+        - os: linux
+          python: 2.7
+        - os: linux
+          python: 3.3
+        - os: linux
+          python: 3.4
+        - os: linux
+          python: 3.5
+        - os: linux
+          python: pypy
+        - os: linux
+          python: pypy3
+        - os: osx
+          language: generic
+          env: TERRYFY_PYTHON='homebrew 2'
+        - os: osx
+          language: generic
+          env: TERRYFY_PYTHON='homebrew 3'
+before_install:
+    - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then git clone https://github.com/MacPython/terryfy; fi
+    - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then source terryfy/travis_tools.sh; fi
+    - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then get_python_environment $TERRYFY_PYTHON venv; fi
+    - if [[ "$TERRYFY_PYTHON" == "homebrew 3" ]]; then alias pip=`which pip3` ; fi
+install:
+    - pip install -e .[ZODB]
+script:
+    - python setup.py -q test -q
+notifications:
+    email: false
+after_success:
+    - echo [distutils]                                  > ~/.pypirc
+    - echo index-servers = pypi                        >> ~/.pypirc
+    - echo [pypi]                                      >> ~/.pypirc
+    - echo repository=https://pypi.python.org/pypi     >> ~/.pypirc
+    - echo username=zope.wheelbuilder                  >> ~/.pypirc
+    - echo password=$PYPIPASSWORD                      >> ~/.pypirc
+    - if [[ $TRAVIS_TAG && "$TRAVIS_OS_NAME" == "osx" ]]; then pip install twine; fi
+    - if [[ $TRAVIS_TAG && "$TRAVIS_OS_NAME" == "osx" ]]; then python setup.py bdist_wheel; fi
+    - if [[ $TRAVIS_TAG && "$TRAVIS_OS_NAME" == "osx" ]]; then twine upload dist/*; fi
+
+env:
+    global:
+        secure: "CpYDbVb6YOyIAnCcvBEiDLeYmNhfDDqJosIV0NussN9dNe1hsfHQK98evAEe9F4kXuWo6SmmtT0uX2RXOojB5If/z7sAcXSDaGWCMJK0FY98sWL2DCRtb1/O1puo/uvn3RJlpe4bkxQoyFCKjpWaTJOM+NSEt7YbTTTdCpG7/zU="
diff --git a/BTrees.egg-info/PKG-INFO b/BTrees.egg-info/PKG-INFO
new file mode 100644
index 0000000..c36025b
--- /dev/null
+++ b/BTrees.egg-info/PKG-INFO
@@ -0,0 +1,245 @@
+Metadata-Version: 1.1
+Name: BTrees
+Version: 4.3.1
+Summary: Scalable persistent object containers
+Home-page: http://packages.python.org/BTrees
+Author: Zope Foundation
+Author-email: zodb-dev at zope.org
+License: ZPL 2.1
+Description: ``BTrees``:  scalable persistent components
+        ===========================================
+        
+        .. image:: https://travis-ci.org/zopefoundation/BTrees.svg?branch=master
+            :target: https://travis-ci.org/zopefoundation/BTrees
+        
+        .. image:: https://ci.appveyor.com/api/projects/status/github/zopefoundation/BTrees?branch=master&svg=true
+            :target: https://ci.appveyor.com/project/mgedmin/BTrees
+        
+        This package contains a set of persistent object containers built around
+        a modified BTree data structure.  The trees are optimized for use inside
+        ZODB's "optimistic concurrency" paradigm, and include explicit resolution
+        of conflicts detected by that mechannism.
+        
+        Please see the Sphinx documentation (``docs/index.rst``) for further
+        information.
+        
+        
+        ``BTrees`` Changelog
+        ====================
+        
+        4.3.1 (2016-05-16)
+        ------------------
+        
+        - Packaging:  fix password used to automate wheel creation on Travis.
+        
+        4.3.0 (2016-05-10)
+        ------------------
+        
+        - Fix unexpected ``OverflowError`` when passing 64bit values to long
+          keys / values on Win64.  See:
+          https://github.com/zopefoundation/BTrees/issues/32
+        
+        - When testing ``PURE_PYTHON`` environments under ``tox``, avoid poisoning
+          the user's global wheel cache.
+        
+        - Ensure that he pure-Python implementation, used on PyPy and when a C
+          compiler isn't available for CPython, pickles identically to the C
+          version. Unpickling will choose the best available implementation.
+          This change prevents interoperability problems and database corruption if
+          both implementations are in use. While it is no longer possible to
+          pickle a Python implementation and have it unpickle to the Python
+          implementation if the C implementation is available, existing Python
+          pickles will still unpickle to the Python implementation (until
+          pickled again). See:
+          https://github.com/zopefoundation/BTrees/issues/19
+        
+        - Avoid creating invalid objects when unpickling empty BTrees in a pure-Python
+          environment.
+        
+        - Drop support for Python 2.6 and 3.2.
+        
+        4.2.0 (2015-11-13)
+        ------------------
+        
+        - Add support for Python 3.5.
+        
+        4.1.4 (2015-06-02)
+        ------------------
+        
+        - Ensure that pure-Python Bucket and Set objects have a human readable
+          ``__repr__`` like the C versions.
+        
+        4.1.3 (2015-05-19)
+        ------------------
+        
+        - Fix ``_p_changed`` when removing items from small pure-Python
+          BTrees/TreeSets and when adding items to small pure-Python Sets. See:
+          https://github.com/zopefoundation/BTrees/issues/13
+        
+        
+        4.1.2 (2015-04-07)
+        ------------------
+        
+        - Suppress testing 64-bit values in OLBTrees on 32 bit machines.
+          See:  https://github.com/zopefoundation/BTrees/issues/9
+        
+        - Fix ``_p_changed`` when adding items to small pure-Python
+          BTrees/TreeSets. See:
+          https://github.com/zopefoundation/BTrees/issues/11
+        
+        
+        4.1.1 (2014-12-27)
+        ------------------
+        
+        - Accomodate long values in pure-Python OLBTrees.
+        
+        
+        4.1.0 (2014-12-26)
+        ------------------
+        
+        - Add support for PyPy and PyPy3.
+        
+        - Add support for Python 3.4.
+        
+        - BTree subclasses can define ``max_leaf_size`` or ``max_internal_size``
+          to control maximum sizes for Bucket/Set and BTree/TreeSet nodes.
+        
+        - Detect integer overflow on 32-bit machines correctly under Python 3.
+        
+        - Update pure-Python and C trees / sets to accept explicit None to indicate
+          max / min value for ``minKey``, ``maxKey``.  (PR #3)
+        
+        - Update pure-Python trees / sets to accept explicit None to indicate
+          open ranges for ``keys``, ``values``, ``items``.  (PR #3)
+        
+        
+        4.0.8 (2013-05-25)
+        ------------------
+        
+        - Fix value-based comparison for objects under Py3k:  addresses invalid
+          merges of ``[OLI]OBTrees/OBuckets``.
+        
+        - Ensure that pure-Python implementation of ``OOBTree.byValue`` matches
+          semantics (reversed-sort) of C implementation.
+        
+        
+        4.0.7 (2013-05-22)
+        ------------------
+        
+        - Issue #2:  compilation error on 32-bit mode of OS/X.
+        
+        - Test ``PURE_PYTHON`` environment variable support:  if set, the C
+          extensions will not be built, imported, or tested.
+        
+        
+        4.0.6 (2013-05-14)
+        ------------------
+        
+        - Changed the ``ZODB`` extra to require only the real ``ZODB`` package,
+          rather than the ``ZODB3`` metapackage:  depending on the version used,
+          the metapackage could pull in stale versions of **this** package and
+          ``persistent``.
+        
+        - Fixed Python version check in ``setup.py``.
+        
+        
+        4.0.5 (2013-01-15)
+        ------------------
+        
+        - Fit the ``repr`` of bucket objects, which could contain garbage
+          characters.
+        
+        
+        4.0.4 (2013-01-12)
+        ------------------
+        
+        - Emulate the (private) iterators used by the C extension modules from
+          pure Python.  This change is "cosmetic" only:  it prevents the ZCML
+          ``zope.app.security:permission.zcml`` from failing.  The emulated
+          classes are **not** functional, and should be considered implementation
+          details.
+        
+        - Accomodate buildout to the fact that we no longer bundle a copy
+          of 'persistent.h'.
+        
+        - Fix test failures on Windows:  no longer rely on overflows from
+          ``sys.maxint``.
+        
+        
+        4.0.3 (2013-01-04)
+        ------------------
+        
+        - Added ``setup_requires==['persistent']``.
+        
+        
+        4.0.2 (2013-01-03)
+        ------------------
+        
+        - Updated Trove classifiers.
+        
+        - Added explicit support for Python 3.2, Python 3.3, and PyPy.
+          Note that the C extensions are not (yet) available on PyPy.
+        
+        - Python reference implementations now tested separately from the C
+          verions on all platforms.
+        
+        - 100% unit test coverage.
+        
+        
+        4.0.1 (2012-10-21)
+        ------------------
+        
+        - Provide local fallback for persistent C header inclusion if the
+          persistent distribution isn't installed. This makes the winbot happy.
+        
+        
+        4.0.0 (2012-10-20)
+        ------------------
+        
+        Platform Changes
+        ################
+        
+        - Dropped support for Python < 2.6.
+        
+        - Factored ``BTrees`` as a separate distribution.
+        
+        Testing Changes
+        ###############
+        
+        - All covered platforms tested under ``tox``.
+        
+        - Added support for continuous integration using ``tox`` and ``jenkins``.
+        
+        - Added ``setup.py dev`` alias (installs ``nose`` and ``coverage``).
+        
+        - Dropped dependency on ``zope.testing`` / ``zope.testrunner``:  tests now
+          run with ``setup.py test``.
+        
+        Documentation Changes
+        #####################
+        
+        - Added API reference, generated via Spinx' autodoc.
+        
+        - Added Sphinx documentation based on ZODB Guide (snippets are exercised
+          via 'tox').
+        
+        - Added ``setup.py docs`` alias (installs ``Sphinx`` and
+          ``repoze.sphinx.autointerface``).
+        
+Platform: any
+Classifier: Development Status :: 6 - Mature
+Classifier: License :: OSI Approved :: Zope Public License
+Classifier: Programming Language :: Python
+Classifier: Programming Language :: Python :: 2
+Classifier: Programming Language :: Python :: 2.7
+Classifier: Programming Language :: Python :: 3
+Classifier: Programming Language :: Python :: 3.3
+Classifier: Programming Language :: Python :: 3.4
+Classifier: Programming Language :: Python :: 3.5
+Classifier: Programming Language :: Python :: Implementation :: CPython
+Classifier: Programming Language :: Python :: Implementation :: PyPy
+Classifier: Framework :: ZODB
+Classifier: Topic :: Database
+Classifier: Topic :: Software Development :: Libraries :: Python Modules
+Classifier: Operating System :: Microsoft :: Windows
+Classifier: Operating System :: Unix
diff --git a/BTrees.egg-info/SOURCES.txt b/BTrees.egg-info/SOURCES.txt
new file mode 100644
index 0000000..1cb9ff1
--- /dev/null
+++ b/BTrees.egg-info/SOURCES.txt
@@ -0,0 +1,92 @@
+.coveragerc
+.gitignore
+.travis.yml
+CHANGES.rst
+COPYRIGHT.txt
+LICENSE.txt
+MANIFEST.in
+README.rst
+appveyor.yml
+bootstrap.py
+buildout.cfg
+setup.cfg
+setup.py
+tox.ini
+BTrees/BTreeItemsTemplate.c
+BTrees/BTreeModuleTemplate.c
+BTrees/BTreeTemplate.c
+BTrees/BucketTemplate.c
+BTrees/Development.txt
+BTrees/IFBTree.py
+BTrees/IIBTree.py
+BTrees/IOBTree.py
+BTrees/Interfaces.py
+BTrees/LFBTree.py
+BTrees/LLBTree.py
+BTrees/LOBTree.py
+BTrees/Length.py
+BTrees/MergeTemplate.c
+BTrees/OIBTree.py
+BTrees/OLBTree.py
+BTrees/OOBTree.py
+BTrees/SetOpTemplate.c
+BTrees/SetTemplate.c
+BTrees/TreeSetTemplate.c
+BTrees/_IFBTree.c
+BTrees/_IIBTree.c
+BTrees/_IOBTree.c
+BTrees/_LFBTree.c
+BTrees/_LLBTree.c
+BTrees/_LOBTree.c
+BTrees/_OIBTree.c
+BTrees/_OLBTree.c
+BTrees/_OOBTree.c
+BTrees/__init__.py
+BTrees/_base.py
+BTrees/_compat.h
+BTrees/_compat.py
+BTrees/_fsBTree.c
+BTrees/check.py
+BTrees/floatvaluemacros.h
+BTrees/fsBTree.py
+BTrees/intkeymacros.h
+BTrees/intvaluemacros.h
+BTrees/nosetests.xml
+BTrees/objectkeymacros.h
+BTrees/objectvaluemacros.h
+BTrees/sorters.c
+BTrees/utils.py
+BTrees.egg-info/PKG-INFO
+BTrees.egg-info/SOURCES.txt
+BTrees.egg-info/dependency_links.txt
+BTrees.egg-info/entry_points.txt
+BTrees.egg-info/not-zip-safe
+BTrees.egg-info/requires.txt
+BTrees.egg-info/top_level.txt
+BTrees/tests/__init__.py
+BTrees/tests/common.py
+BTrees/tests/testBTrees.py
+BTrees/tests/testBTreesUnicode.py
+BTrees/tests/testConflict.py
+BTrees/tests/test_IFBTree.py
+BTrees/tests/test_IIBTree.py
+BTrees/tests/test_IOBTree.py
+BTrees/tests/test_LFBTree.py
+BTrees/tests/test_LLBTree.py
+BTrees/tests/test_LOBTree.py
+BTrees/tests/test_Length.py
+BTrees/tests/test_OIBTree.py
+BTrees/tests/test_OLBTree.py
+BTrees/tests/test_OOBTree.py
+BTrees/tests/test__base.py
+BTrees/tests/test_btreesubclass.py
+BTrees/tests/test_check.py
+BTrees/tests/test_fsBTree.py
+BTrees/tests/test_utils.py
+docs/Makefile
+docs/api.rst
+docs/conf.py
+docs/index.rst
+docs/make.bat
+docs/_static/placeholder.txt
+docs/_templates/placeholder.txt
\ No newline at end of file
diff --git a/BTrees.egg-info/dependency_links.txt b/BTrees.egg-info/dependency_links.txt
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/BTrees.egg-info/dependency_links.txt
@@ -0,0 +1 @@
+
diff --git a/BTrees.egg-info/entry_points.txt b/BTrees.egg-info/entry_points.txt
new file mode 100644
index 0000000..5c979ee
--- /dev/null
+++ b/BTrees.egg-info/entry_points.txt
@@ -0,0 +1 @@
+      
\ No newline at end of file
diff --git a/BTrees.egg-info/not-zip-safe b/BTrees.egg-info/not-zip-safe
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/BTrees.egg-info/not-zip-safe
@@ -0,0 +1 @@
+
diff --git a/BTrees.egg-info/requires.txt b/BTrees.egg-info/requires.txt
new file mode 100644
index 0000000..8eafccc
--- /dev/null
+++ b/BTrees.egg-info/requires.txt
@@ -0,0 +1,21 @@
+persistent
+zope.interface
+
+[ZODB]
+ZODB
+
+[docs]
+Sphinx
+repoze.sphinx.autointerface
+
+[test]
+persistent
+zope.interface
+transaction
+
+[testing]
+persistent
+zope.interface
+transaction
+nose
+coverage
diff --git a/BTrees.egg-info/top_level.txt b/BTrees.egg-info/top_level.txt
new file mode 100644
index 0000000..67528a2
--- /dev/null
+++ b/BTrees.egg-info/top_level.txt
@@ -0,0 +1 @@
+BTrees
diff --git a/BTrees/BTreeItemsTemplate.c b/BTrees/BTreeItemsTemplate.c
new file mode 100644
index 0000000..148480a
--- /dev/null
+++ b/BTrees/BTreeItemsTemplate.c
@@ -0,0 +1,790 @@
+/*****************************************************************************
+
+  Copyright (c) 2001, 2002 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
+
+ ****************************************************************************/
+
+#define BTREEITEMSTEMPLATE_C "$Id$\n"
+
+/* A BTreeItems struct is returned from calling .items(), .keys() or
+ * .values() on a BTree-based data structure, and is also the result of
+ * taking slices of those.  It represents a contiguous slice of a BTree.
+ *
+ * The start of the slice is in firstbucket, at offset first.  The end of
+ * the slice is in lastbucket, at offset last.  Both endpoints are inclusive.
+ * It must possible to get from firstbucket to lastbucket via following
+ * bucket 'next' pointers zero or more times.  firstbucket, first, lastbucket,
+ * and last are readonly after initialization.  An empty slice is represented
+ * by  firstbucket == lastbucket == currentbucket == NULL.
+ *
+ * 'kind' determines whether this slice represents 'k'eys alone, 'v'alues
+ * alone, or 'i'items (key+value pairs).  'kind' is also readonly after
+ * initialization.
+ *
+ * The combination of currentbucket, currentoffset and pseudoindex acts as
+ * a search finger.  Offset currentoffset in bucket currentbucket is at index
+ * pseudoindex, where pseudoindex==0 corresponds to offset first in bucket
+ * firstbucket, and pseudoindex==-1 corresponds to offset last in bucket
+ * lastbucket.  The function BTreeItems_seek() can be used to set this combo
+ * correctly for any in-bounds index, and uses this combo on input to avoid
+ * needing to search from the start (or end) on each call.  Calling
+ * BTreeItems_seek() with consecutive larger positions is very efficent.
+ * Calling it with consecutive smaller positions is more efficient than if
+ * a search finger weren't being used at all, but is still quadratic time
+ * in the number of buckets in the slice.
+ */
+typedef struct
+{
+    PyObject_HEAD
+    Bucket *firstbucket;    /* First bucket                    */
+    Bucket *currentbucket;  /* Current bucket (search finger) */
+    Bucket *lastbucket;     /* Last bucket                    */
+    int currentoffset;      /* Offset in currentbucket        */
+    int pseudoindex;        /* search finger index            */
+    int first;              /* Start offset in firstbucket    */
+    int last;               /* End offset in lastbucket       */
+    char kind;              /* 'k', 'v', 'i'                  */
+} BTreeItems;
+
+#define ITEMS(O)((BTreeItems*)(O))
+
+static PyObject *
+newBTreeItems(char kind,
+              Bucket *lowbucket, int lowoffset,
+              Bucket *highbucket, int highoffset);
+
+static void
+BTreeItems_dealloc(BTreeItems *self)
+{
+    Py_XDECREF(self->firstbucket);
+    Py_XDECREF(self->lastbucket);
+    Py_XDECREF(self->currentbucket);
+    PyObject_DEL(self);
+}
+
+static Py_ssize_t
+BTreeItems_length_or_nonzero(BTreeItems *self, int nonzero)
+{
+    Py_ssize_t r;
+    Bucket *b, *next;
+
+    b = self->firstbucket;
+    if (b == NULL)
+        return 0;
+
+    r = self->last + 1 - self->first;
+
+    if (nonzero && r > 0)
+    /* Short-circuit if all we care about is nonempty */
+        return 1;
+
+    if (b == self->lastbucket)
+        return r;
+
+    Py_INCREF(b);
+    PER_USE_OR_RETURN(b, -1);
+    while ((next = b->next))
+    {
+        r += b->len;
+        if (nonzero && r > 0)
+            /* Short-circuit if all we care about is nonempty */
+            break;
+
+        if (next == self->lastbucket)
+            break; /* we already counted the last bucket */
+
+        Py_INCREF(next);
+        PER_UNUSE(b);
+        Py_DECREF(b);
+        b = next;
+        PER_USE_OR_RETURN(b, -1);
+    }
+    PER_UNUSE(b);
+    Py_DECREF(b);
+
+    return r >= 0 ? r : 0;
+}
+
+static Py_ssize_t
+BTreeItems_length(BTreeItems *self)
+{
+    return BTreeItems_length_or_nonzero(self, 0);
+}
+
+/*
+** BTreeItems_seek
+**
+** Find the ith position in the BTreeItems.
+**
+** Arguments:      self    The BTree
+**        i    the index to seek to, in 0 .. len(self)-1, or in
+**                      -len(self) .. -1, as for indexing a Python sequence.
+**
+**
+** Returns 0 if successful, -1 on failure to seek (like out-of-bounds).
+** Upon successful return, index i is at offset self->currentoffset in bucket
+** self->currentbucket.
+*/
+static int
+BTreeItems_seek(BTreeItems *self, Py_ssize_t i)
+{
+    int delta, pseudoindex, currentoffset;
+    Bucket *b, *currentbucket;
+    int error;
+
+    pseudoindex = self->pseudoindex;
+    currentoffset = self->currentoffset;
+    currentbucket = self->currentbucket;
+    if (currentbucket == NULL)
+        goto no_match;
+
+    delta = i - pseudoindex;
+    while (delta > 0) /* move right */
+    {
+        int max;
+        /* Want to move right delta positions; the most we can move right in
+         * this bucket is currentbucket->len - currentoffset - 1 positions.
+         */
+        PER_USE_OR_RETURN(currentbucket, -1);
+        max = currentbucket->len - currentoffset - 1;
+        b = currentbucket->next;
+        PER_UNUSE(currentbucket);
+        if (delta <= max)
+        {
+            currentoffset += delta;
+            pseudoindex += delta;
+            if (currentbucket == self->lastbucket
+                && currentoffset > self->last)
+                goto no_match;
+            break;
+        }
+        /* Move to start of next bucket. */
+        if (currentbucket == self->lastbucket || b == NULL)
+            goto no_match;
+        currentbucket = b;
+        pseudoindex += max + 1;
+        delta -= max + 1;
+        currentoffset = 0;
+    }
+    while (delta < 0) /* move left */
+    {
+        int status;
+        /* Want to move left -delta positions; the most we can move left in
+         * this bucket is currentoffset positions.
+         */
+        if ((-delta) <= currentoffset)
+        {
+            currentoffset += delta;
+            pseudoindex += delta;
+            if (currentbucket == self->firstbucket
+                && currentoffset < self->first)
+                goto no_match;
+            break;
+        }
+        /* Move to end of previous bucket. */
+        if (currentbucket == self->firstbucket)
+            goto no_match;
+        status = PreviousBucket(&currentbucket, self->firstbucket);
+        if (status == 0)
+            goto no_match;
+        else if (status < 0)
+            return -1;
+        pseudoindex -= currentoffset + 1;
+        delta += currentoffset + 1;
+        PER_USE_OR_RETURN(currentbucket, -1);
+        currentoffset = currentbucket->len - 1;
+        PER_UNUSE(currentbucket);
+    }
+
+    assert(pseudoindex == i);
+
+    /* Alas, the user may have mutated the bucket since the last time we
+     * were called, and if they deleted stuff, we may be pointing into
+     * trash memory now.
+     */
+    PER_USE_OR_RETURN(currentbucket, -1);
+    error = currentoffset < 0 || currentoffset >= currentbucket->len;
+    PER_UNUSE(currentbucket);
+    if (error)
+    {
+        PyErr_SetString(PyExc_RuntimeError,
+                        "the bucket being iterated changed size");
+        return -1;
+    }
+
+    Py_INCREF(currentbucket);
+    Py_DECREF(self->currentbucket);
+    self->currentbucket = currentbucket;
+    self->currentoffset = currentoffset;
+    self->pseudoindex = pseudoindex;
+    return 0;
+
+no_match:
+    IndexError(i);
+    return -1;
+}
+
+
+/* Return the right kind ('k','v','i') of entry from bucket b at offset i.
+ *  b must be activated.  Returns NULL on error.
+ */
+static PyObject *
+getBucketEntry(Bucket *b, int i, char kind)
+{
+    PyObject *result = NULL;
+
+    assert(b);
+    assert(0 <= i && i < b->len);
+
+    switch (kind)
+    {
+        case 'k':
+            COPY_KEY_TO_OBJECT(result, b->keys[i]);
+            break;
+
+        case 'v':
+            COPY_VALUE_TO_OBJECT(result, b->values[i]);
+            break;
+
+        case 'i':
+        {
+            PyObject *key;
+            PyObject *value;;
+
+            COPY_KEY_TO_OBJECT(key, b->keys[i]);
+            if (!key)
+                break;
+
+            COPY_VALUE_TO_OBJECT(value, b->values[i]);
+            if (!value)
+            {
+                Py_DECREF(key);
+                break;
+            }
+
+            result = PyTuple_New(2);
+            if (result)
+            {
+                PyTuple_SET_ITEM(result, 0, key);
+                PyTuple_SET_ITEM(result, 1, value);
+            }
+            else
+            {
+                Py_DECREF(key);
+                Py_DECREF(value);
+            }
+            break;
+        }
+
+        default:
+            PyErr_SetString(PyExc_AssertionError,
+                            "getBucketEntry: unknown kind");
+            break;
+    }
+    return result;
+}
+
+/*
+** BTreeItems_item
+**
+** Arguments:    self    a BTreeItems structure
+**        i    Which item to inspect
+**
+** Returns:    the BTreeItems_item_BTree of self->kind, i
+**        (ie pulls the ith item out)
+*/
+static PyObject *
+BTreeItems_item(BTreeItems *self, Py_ssize_t i)
+{
+    PyObject *result;
+
+    if (BTreeItems_seek(self, i) < 0)
+        return NULL;
+
+    PER_USE_OR_RETURN(self->currentbucket, NULL);
+    result = getBucketEntry(self->currentbucket, self->currentoffset,
+                            self->kind);
+    PER_UNUSE(self->currentbucket);
+    return result;
+}
+
+/*
+** BTreeItems_slice
+**
+** Creates a new BTreeItems structure representing the slice
+** between the low and high range
+**
+** Arguments:    self    The old BTreeItems structure
+**        ilow    The start index
+**        ihigh    The end index
+**
+** Returns:    BTreeItems item
+*/
+static PyObject *
+BTreeItems_slice(BTreeItems *self, Py_ssize_t ilow, Py_ssize_t ihigh)
+{
+    Bucket *lowbucket;
+    Bucket *highbucket;
+    int lowoffset;
+    int highoffset;
+    Py_ssize_t length = -1;  /* len(self), but computed only if needed */
+
+    /* Complications:
+     * A Python slice never raises IndexError, but BTreeItems_seek does.
+     * Python did only part of index normalization before calling this:
+     *     ilow may be < 0 now, and ihigh may be arbitrarily large.  It's
+     *     our responsibility to clip them.
+     * A Python slice is exclusive of the high index, but a BTreeItems
+     *     struct is inclusive on both ends.
+     */
+
+    /* First adjust ilow and ihigh to be legit endpoints in the Python
+     * sense (ilow inclusive, ihigh exclusive).  This block duplicates the
+     * logic from Python's list_slice function (slicing for builtin lists).
+     */
+    if (ilow < 0)
+        ilow = 0;
+    else
+    {
+        if (length < 0)
+            length = BTreeItems_length(self);
+        if (ilow > length)
+            ilow = length;
+    }
+
+    if (ihigh < ilow)
+        ihigh = ilow;
+    else
+    {
+        if (length < 0)
+            length = BTreeItems_length(self);
+        if (ihigh > length)
+            ihigh = length;
+    }
+    assert(0 <= ilow && ilow <= ihigh);
+    assert(length < 0 || ihigh <= length);
+
+    /* Now adjust for that our struct is inclusive on both ends.  This is
+    * easy *except* when the slice is empty:  there's no good way to spell
+    * that in an inclusive-on-both-ends scheme.  For example, if the
+    * slice is btree.items([:0]), ilow == ihigh == 0 at this point, and if
+    * we were to subtract 1 from ihigh that would get interpreted by
+    * BTreeItems_seek as meaning the *entire* set of items.  Setting ilow==1
+    * and ihigh==0 doesn't work either, as BTreeItems_seek raises IndexError
+    * if we attempt to seek to ilow==1 when the underlying sequence is empty.
+    * It seems simplest to deal with empty slices as a special case here.
+    */
+    if (ilow == ihigh) /* empty slice */
+    {
+        lowbucket = highbucket = NULL;
+        lowoffset = 1;
+        highoffset = 0;
+    }
+    else
+    {
+        assert(ilow < ihigh);
+        --ihigh;  /* exclusive -> inclusive */
+
+        if (BTreeItems_seek(self, ilow) < 0)
+            return NULL;
+        lowbucket = self->currentbucket;
+        lowoffset = self->currentoffset;
... 26484 lines suppressed ...

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-btrees.git



More information about the Python-modules-commits mailing list