基于咆哮位图的压缩整数集。

croaring的Python项目详细描述


Roaring bitmaps快速,压缩, 和便携式位图,用于存储唯一排序的整数集。这些 位图提供了比现实世界更好的空间复杂度和性能。 典型的散列集(例如python的内置set),可以是 序列化为可移植格式,以便存储和与 C/C++、Java和GO库。

这个图书馆使 CRoaring实现 在Python2.7和3.5+中提供。它使用 CFFI,所以它对两个都有效 cpython和pypy。实现了完整的python set接口。 包括全面测试。

安装

pip install croaring

croaring源代码包含在python库中,因此 需要从其他地方安装它(尽管您可能需要一个C编译器 如果二进制软件包不适用于您的体系结构,则可用。

用法

实例化一个croaring.RoaringBitmap(),并像 正常set

>>> import croaring
>>> bitmap = croaring.RoaringBitmap()
>>> bitmap
RoaringBitmap([])
>>> bitmap.add(1)
>>> bitmap.add(4572)
>>> bitmap.add(326)
>>> bitmap
RoaringBitmap([1, 326, 4572])

您可以使用二进制运算符(|&^-)或 他们的英文名字(unionintersectionsymmetric_differencedifference):

>>> bitmap | RoaringBitmap([50, 95])
RoaringBitmap([1, 50, 95, 326, 4572])
>>> bitmap & RoaringBitmap([200, 326])
RoaringBitmap([326])
>>> bitmap ^ RoaringBitmap([200, 326])
RoaringBitmap([1, 200, 4572])
由于位图是有序的,索引(包括负)是 支持:

>>> bitmap[1]
326
>>> bitmap[-1]
4572

最后,您可以从一个范围构造一个位图,类似于 python内置的参数range

>>> RoaringBitmap.range(10)
RoaringBitmap([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
>>> RoaringBitmap.range(2, 10)
RoaringBitmap([2, 3, 4, 5, 6, 7, 8, 9])
>>> RoaringBitmap.range(2, 10, 3)
RoaringBitmap([2, 5, 8])

许可证

Croaring是根据Apache许可证v2.0获得许可的:

Copyright 2016 The CRoaring authors

Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

所有其他代码在未经许可的情况下发布:

This is free and unencumbered software released into the public domain.

Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means.

In jurisdictions that recognize copyright laws, the author or authors of this software dedicate any and all copyright interest in the software to the public domain. We make this dedication for the benefit of the public at large and to the detriment of our heirs and successors. We intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights to this software under copyright law.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

For more information, please refer to http://unlicense.org/

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java按钮在可展开列表视图中不可单击   java类声明对象类型不明确   java使用单独的类从Get和Set方法获取值   java Spring引导集成测试不读取属性文件   java如何为函数中带注释的参数编写mockito   java在调整JFrame的大小时消除了组件之间的额外空间   Java流筛选器空指针问题   为什么java会这么做。util。可选的没有一些和没有子类?   java Android广播接收器作为传递字符串的内部静态类   Java中使用迭代器的集合类型推断?   java在JUnit测试中获取JAR列表   java从命名的Linux管道读取BufferedInputStream只工作一次   java是使用值对地图进行排序的最佳方法   位操作有人知道为什么我的java代码使用n=n/2不能正常工作,而n>>1能正常工作吗?   java数据已从mysql中选择,但该过程引发NullPointerException   java如何将文本从控制台传递到文本编辑器   java如何在不使用adb命令的情况下通过USB连接到pc的安卓设备的互联网连接?   Spring是如何使用Java8类的,但它运行在Java7上的?   java仅仅通过类型参数创建泛型类?