Commit cf9ba53a authored by Jason Fried's avatar Jason Fried Committed by Facebook Github Bot

Add ByteRange/StringPiece Conversion for Cython

Summary:
Moving the cython definition to folly/python.
Adding simple conversion helper to_bytes

This is to cut down on duplicate folly::range cython definitions

Reviewed By: yfeldblum

Differential Revision: D6291125

fbshipit-source-id: 314b732a1516a03fb5c9a57939552bbabd81970b
parent 5273dbe9
cdef extern from "folly/Range.h" namespace "folly":
cdef cppclass Range[T]:
Range()
Range(T, int)
T data()
int size()
ctypedef Range[const char*] StringPiece
ctypedef Range[const unsigned char*] ByteRange
ctypedef fused R:
StringPiece
ByteRange
# Conversion Helpers
cdef inline bytes to_bytes(R range):
return <bytes>range.data()[:range.size()]
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