<p>I'm looking for a production quality bloom filter implementation in Python to handle fairly large numbers of items (say 100M to 1B items with 0.01% false positive rate). </p>

<p><a href="http://www.imperialviolet.org/pybloom.html" rel="noreferrer">Pybloom</a> is one option but it seems to be showing its age as it throws DeprecationWarning errors  on Python 2.5 on a regular basis. Joe Gregorio also has <a href="http://bitworking.org/news/380/bloom-filter-resources" rel="noreferrer">an implementation</a>. </p>

<p>Requirements are fast lookup performance and stability. I'm also open to creating Python interfaces to particularly good c/c++ implementations, or even to Jython if there's a good Java implementation.</p>

<p>Lacking that, any recommendations on a bit array / bit vector representation that can handle ~16E9 bits?</p>

Look at the
array
module.
```
```
class Bit( object ):
    def __init__( self, size ):
        self.bits= array.array('B',[0 for i in range((size+7)//8)] )
    def set( self, bit ):
        b= self.bits[bit//8]
        self.bits[bit//8] = b | 1 << (bit % 8)
    def get( self, bit ):
        b= self.bits[bit//8]
        return (b >> (bit % 8)) & 1
```
```
FWIW, all of the
```
//8
```
and
```
% 8
```
operations can be replaced with
```
>>3
```
and
```
&0x07
```
.  This
may
lead to slightly better speed at the risk of some obscurity.
Also, changing
```
'B'
```
and
```
8
```
to
```
'L'
```
and
```
32
```
should be faster on most hardware.  [Changing to
```
'H'
```
and 16 might be faster on some hardware, but it's doubtful.]