There was no way to pass an already-encoded string to `builder.CreateString` in Python 2.7: - Passing a `bytearray` raised a TypeError because `bytearray` was not recognized as an instance of `compat.binary_type`. - Passing a utf-8 encoded `str` would cause the string to be double-encoded, because `compat.string_types = (basestring,)` and `basestring` is the base class of `str` and `unicode`, so the logic would never reach the `elif isinstance(s, compat.binary_type)` case. - Converting a utf-8 encoded bytearray to `bytes` like `builder.CreateString(bytes(encoded_string))` does not work because in Python 2.7, bytes is just an alias for `str` so it behaves as above. This change allows either `bytes` or `bytearray` as an already-encoded string to be passed to `CreateString` in versions of Python that support `bytearray`, and falls back to `str` in older versions. In Python 2, it restricts unencoded string types to `unicode`, so `str` can be used as an encoded, binary representaiton.
FlatBuffers 
FlatBuffers is an efficient cross platform serialization library for games and other memory constrained apps. It allows you to directly access serialized data without unpacking/parsing it first, while still having great forwards/backwards compatibility.
Go to our landing page to browse our documentation.
Supported operating systems
- Android
- Windows
- MacOS X
- Linux
Supported programming languages
- C++
- C#
- Go
- Java
- JavaScript
- PHP
- Python
and many more in progress...
Contribution
- FlatBuffers Google Group to discuss FlatBuffers with other developers and users.
- FlatBuffers Issues Tracker to submit an issue.
- stackoverflow.com with
flatbufferstag for any questions regarding FlatBuffers.
To contribute to this project, see CONTRIBUTING.
Integration
For applications on Google Play that integrate this tool, usage is tracked.
This tracking is done automatically using the embedded version string
(flatbuffer_version_string), and helps us continue to optimize it. Aside from
consuming a few extra bytes in your application binary, it shouldn't affect
your application at all. We use this information to let us know if FlatBuffers
is useful and if we should continue to invest in it. Since this is open
source, you are free to remove the version string but we would appreciate if
you would leave it in.
Licensing
Flatbuffers is licensed under the Apache License, Version 2.0. See LICENSE for the full license text.