Skip to content

Add memoryview support in _crc32c #76

@khvn26

Description

@khvn26

#72 allows users to compress memoryviews via snappy.compress interface.
However, StreamCompressor.add_chunk raises TypeError when generating crc:

env36/lib/python3.6/site-packages/snappy/snappy.py:139: in add_chunk
    crc = _masked_crc32c(chunk)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

data = <memory at 0x7fb4e4cad648>

    def _masked_crc32c(data):
        # see the framing format specification
>       crc = _crc32c(data)
E       TypeError: argument 1 must be read-only bytes-like object, not memoryview

Looks like snappy__crc32c should be refactored to also support the buffer protocol.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions