summaryrefslogtreecommitdiff
path: root/python
AgeCommit message (Collapse)AuthorFilesLines
2023-01-21FlatBuffers Version 23.1.21 (#7796)Derek Bailey2-2/+2
2023-01-21Flatbuffers Version 23.1.20 (#7794)Michael Le2-2/+2
* Flatbuffers Version 23.1.20 * Fix warnings * Fix warnings
2023-01-10Fix Python host-endianness dependencies (#7773)Ben Beasley1-5/+5
* In Python tests, use host-endian-independent dtypes * Fix host endianness dependence in Python flexbuffers Co-authored-by: Derek Bailey <derekbailey@google.com>
2023-01-04FlatBuffers Version 23.1.4 (#7758)Derek Bailey2-2/+2
2022-12-14Add Ref.AsStringBytes to flatbuffers.flexbuffers Python API (#7713)Jared Junyoung Lim1-0/+9
* Add Ref.AsStringBytes to flatbuffers.flexbuffers Python API * Append Bytes to AsStringBytes return value Co-authored-by: Jared Junyoung Lim <jaredlim@google.com>
2022-12-06FlatBuffers Version 22.12.06 (#7702)Derek Bailey2-2/+2
2022-12-05Add LICENSE.txt to python (#7692)RishabhDeep Singh2-0/+5
* Add LICENSE.txt to python * Remove LICENSE.txt from python path and used the root LICENSE.txt file
2022-11-23FlatBuffers Version 22.11.23 (#7662)Derek Bailey2-2/+2
2022-11-22FlatBuffers Version 22.11.22Derek Bailey2-2/+2
2022-10-29Add CreateSharedString to python builder (#7608)Michael Le1-1/+17
Co-authored-by: Derek Bailey <derekbailey@google.com>
2022-10-26FlatBuffers Version 22.10.26 (#7607)Derek Bailey2-9/+4
2022-10-26`setup.py`: Define version directlyDerek Bailey1-37/+2
Define the version directly instead of loading from an environment variable and writing to a file.
2022-10-26FlatBuffers Version 22.10.25 (#7604)Derek Bailey1-1/+1
2022-10-06Add support for metadata attributes for enum values (#7567) (#7568)Piotr DziwiƄski1-1/+32
* Add support for metadata attributes for enum values (#7567) * Fix path lookup in flatc test * Try a fix for Windows paths * Convert path to string to fix Windows error
2022-09-29FlatBuffers Version 22.9.29 (#7557)Derek Bailey1-1/+1
2022-09-27FlatBuffers Version 22.9.24 (#7547)Derek Bailey1-1/+1
2022-09-22[Python] Python fixed size array (#7529)Joshua Smith1-1/+10
* feat: Added support for fixed sized arrays to python Problem: We encountered that using fixed arrays from C++ to python that python would not read those arrays correctly due to no size information being encoded in the byte array itself. Fix: Encode the sizes within the generated python file during code generation. Specfically we add GetArrayAsNumpy to the python version of table, which takes as input the length of the vector. When generating the python message files we include this length from the VectorType().fixed_length. * fix: added digit support for camel case to snake case conversion Problem: When including a number in the message name we would encounter cases where SnakeCase would not add the appropirate breaks. e.g. Int32Stamped -> int_32stamped rather than int_32_stamped. Fix: To fix this we can add the condition that we check if the current character is not lower and not a digit, that we check if the previous character was a lower or digit. If it was a lower or digit then we add the break. * fix: Array support for structures Problem: The python generated code for handling non-struct and struct vectors and arrays was inconsistent. The calls to populate the obj api was creating incorrect code. Solution: To fix this the VectorOfStruct and VectorOfNonStruct was rewritten to handle array cases and bring the two methods in line which each other. Testing: PythonTesting.sh now correctly runs and generates the code for array_test.fbs. Minor modifications were done on the test to use the new index accessor for struct arrays and the script correctly sources the location of the python code. * chore: clang format changes * Added code generated by scripts/generate_code. Modified GetArrayOfNonStruct slightly to allow for function overloading allowing the user to get a single element of an array or the whole array. * Added new_line parameter to OffsetPrefix to allow optional new lines to be added. This allows us to use the GenIndents method that automatically adds new lines instead. * Reupload of generated code from the scripts/generate_code.py * Removed new line in GetVectorAsNumpy. * Updated Array lengths to use Length methods where possible. Added fallthrough for GenTypePointer. Added digit check to CamelToSnake method. Added and modified tests for ToSnakeCase and CamelToSnake. * Added range check on the getter methods for vector and array types. Renamed == as is for python
2022-08-29FlatBuffers Version 2.0.8 (#7492)Derek Bailey1-1/+1
2022-06-13Implement optional scalars for Python (#7318)Caleb Zulawski1-3/+5
* Implement optional scalars for Python * Use == for integer comparison, remove empty line * Fix optional type hint Co-authored-by: Caleb Zulawski <caleb.zulawski@caci.com>
2022-04-15Add parameter back to EndVector (#7246)Derek Bailey1-1/+17
2022-02-10Add reflection support for python (#7026)qazwsxedcrfvtg1413-0/+1395
We already have the reflection.fbs file and the flatbuffers python language support. Adding this feature would give the python developers the ability to parse the flatbuffers schema and write some tools. Co-authored-by: Derek Bailey <derekbailey@google.com>
2021-06-17Fix warning about deprecated module: imp (#6362)Neil Girdhar1-6/+11
2020-12-14Add vectorNumElements attribute to Builder for simpler vector creation. (#6328)Richard A Hofer1-6/+11
* Add vectorNumElements attribute to Builder for simpler vector creation. This adds a default to EndVector which should simplify its use. * Update tutorial to reflect new default arg in Python EndVector. * Remove optional argument to Python EndVector. * Add generated files. * Unset Builder.vectorNumElems when not in use.
2020-12-07Set default initialSize for Builder to 0 (#6310)Richard A Hofer1-1/+1
* Set default initialSize for Builder to 0 * Change default size of builder to 1024. This matches what the C++ and Java versions do.
2020-07-30export a __version__ variable for python module (#5309)Omer Akram3-1/+32
* export a __version__ variable for python module * assign version to be used below * better support python2 * Add copyright header
2020-05-07Implement flexbuffers in python (#5880)Dmitriy Kovalev1-0/+1527
2020-03-09Fix Python min alignmentWouter van Oortmerssen1-3/+10
This was accidentally deleted in: https://github.com/google/flatbuffers/commit/9fa8245e81a2fd8ad19f9ae8f3da3a00e796e462 Change-Id: I8cad721e075279f6a67aca81259f73fb75aba482
2020-02-12[Python] Fixed potential allignment issue (#5768)Joseph Pyott1-2/+2
2020-02-11[Python] Fixed issue #5499 (#5764)Joseph Pyott1-0/+1
2019-10-17Python: Add forceDefaults opt to python Builder (#5564)Bharat Tak1-4/+13
* Add forceDefaults opt to python Builder * Add test functions for force_default option for python builder * Simplify * Add force default test for UOffsetTFlags
2019-07-26Python: Added support for file_identifiers (#5123)Joseph Pyott3-9/+34
* Python: Added support for file_identifiers * Added tests. Fixed file_identifier code. * Python: Fixed excessive padding of file_identifier. Repaired tests. * Python: Made code compatible with python2.7 * Python: Typo fix in @endcond * whitespace normaalization * Stylistic change from if(not X is None) to if(X is not None). Added comment to type string. * Python: Added support for automatic code generation of file_identifiers. Added tests for said code generation. * converted sprintf to snprintf * Bugfix, added snprint deffinition for MSVC * changed snprint deffinition for MSVC to sprint_s * changed scanf to IntToStringHex. Renamed HasFileIdentifier to GenHasFileIdentifier. * Added updated genereated code to commit * Python bugix: flatc no longer produces HasFileIdentfier for shcemas with no file identifier * Added tests to verify `MonsterBufferHasIdentifier` returns false on no Identifier * Python: added tests for GetBufferIdentifier and BufferHasIdentifier Python: removed unessasary parenethesis in if statements Minor format changes. * Python : correceted instances of keyword arguments being called as positional arguments * fixed typos and grammer in comments * Minor style fixes * Indentation fix * Equals style changes * Python: Fixed Alignment Issues. Changed test code to test against atual output * Ran make(forgot to run make last commit) * Python: Style changes * Style changes * indentation and style * readded CONTRIBUTING.md * Formatting tweak Mostly to make CI run again * More formatting fixes * More formatting fixes * More formatting fixes * More formatting fixes * Formatting fix * More formatting fixes * Formatting * ran generate_code.sh
2019-05-08[Python PyPI] Added classifiers and more links. Fixes typo and #5215 (#5272)Will Stott1-3/+17
2019-05-06Use a hash table to index existing vtables (#5314)Malthe Borch1-41/+33
* Use a hash table to index existing vtables This allows for quick deduplication even in situations where there might be thousands of vtables due to 'combinatoric explosion'. This fixes issue #5301. * Refactor 0-offset trimming * Improve deduplication benchmark The routine now generates a set of realistic logical layouts and uses a timer function that randomly picks a layout for each iteration. The benchmark runs in batches of # of logical layouts = 1, 10, 100, 1000. (Note that due to alignment, the actual number of vtables is usually slightly higher.)
2018-10-15[Python] Fast serialization of numpy vectors (#4829)Felix Frank1-1/+37
[Python] Fast serialization of numpy vectors (#4829)
2018-07-23python: do not clobber minalign when we create objects (#4833)Robert1-1/+0
2018-06-25Added setup.cfg to default to python 2/3 wheels for pypi.Wouter van Oortmerssen1-0/+2
Change-Id: I64cf42aca79c32d21cd15c1415125ba97665d134
2018-03-12Java/C#/Python prefixed size support (#4445)Robert Schmidtke2-2/+48
* initial changes to support size prefixed buffers in Java * add slice equivalent to CSharp ByteBuffer * resolve TODO for slicing in CSharp code generation * add newly generated Java and CSharp test sources * fix typo in comment * add FinishSizePrefixed methods to CSharp FlatBufferBuilder as well * add option to allow writing the prefix as well * generate size-prefixed monster binary as well * extend JavaTest to test the size prefixed binary as well * use constants for size prefix length * fuse common code for getRootAs and getSizePrefixedRootAs * pulled file identifier out of if * add FinishSizePrefixed, GetSizePrefixedRootAs support for Python * Revert "extend JavaTest to test the size prefixed binary as well" This reverts commit 68be4420dda47e8d0600bb19691f03be71503a68. * Revert "generate size-prefixed monster binary as well" This reverts commit 2939516fdf78df4f061c627221e232b312301417. * fix ByteBuffer.cs Slice() method; add proper CSharp and Java tests * fix unused parameter * increment version number * pulled out generated methods into separate utility class * pulled out generated methods into separate utility class for Python * fix indentation * remove unnecessary comment * fix newline and copyright * add ByteBufferUtil to csproj compilation * hide ByteBuffer's internal data; track offset into parent's array * test unsafe versions as well; compile and run in debug mode * clarify help text for size prefix * move ByteBuffer slicing behavior to subclass * fix protection levels * add size prefix support for text generation * add ByteBufferSlice to csproj compilation * revert size prefix handling for nested buffers * use duplicate instead of slice for removing size prefix * remove slice subclass and use duplicate for removing size prefix * remove slice specific tests * remove superfluous command line option
2017-11-27Add support for Python lib continuous deployment.Michael Holler2-1/+30
Use a combination of travis and twine to publish to PyPI. New publications will be made: * When `master` is updated. This will trigger the publication of a the Python artifact versioned an iso-compliant build datetime. In this way, the cutting edge version will always be available via PyPI. * When a new git tag is pushed. Tag pushes trigger the publication of a python artifact with the same version as the git tag, with the leading `v` stripped if present (`v1.2.3` becomes `1.2.3`). Publications rely on Travis having a PYPI_PASSWORD environment set in the project settings. See the Travis CI documentation for information on [setting environment variables which containing sensitive data][1]. Make extra sure the "Display value in build log" switch is OFF. In addition to setting the previously mentioned `PYPI_PASSWORD` environment variable, the owner of the PyPI `flatbuffers` repository should, after merging this commit into master, add his own commit to change `mikeholler` in `.travis/deploy-python.sh` to his username. It's also recommended that the owner of `flatbuffers` use a separate account in the unlikely event that the environment variable somehow becomes compromised. Again, this is very unlikely, since the environment variable is only set for "safe" builds approved by maintainers (not on random pull requests). [1]: https://docs.travis-ci.com/user/environment-variables/#Defining-Variables-in-Repository-Settings
2017-10-06Python: CreateByteVector function in builder. (#4453)Robert1-0/+21
2017-08-24Trimmed vtables of trailing zeroes.Wouter van Oortmerssen1-0/+4
This is something the format supports, but none of the builders were doing. Can save 10-20% on FlatBuffer binary size! Also fixed the Go tests. Change-Id: I616c56ce9bbcfcaee23aa24f0532fcb60b6a8c75 Tested: on Linux.
2017-08-01[Python] (scalar) vector reading speedup via numpy (#4390)Kevin Rose4-3/+72
* Add numpy accessor to python flatbuffers scalar vectors * Update python tests to test numpy vector accessor * Update appveyor CI to run Python tests, save generated code as artifact * Update example generated python code * Add numpy info to python usage docs * Update test schema and python tests w/ multi-byte vector * did not mean to push profiling code * adding float64 numpy tests
2016-05-23Added missing licenses to some sh/cs/py files.Wouter van Oortmerssen3-0/+42
Bug: https://github.com/google/flatbuffers/issues/3872 Change-Id: I5d551168e9bc925e867e5e4ddf5d809418fd44eb Tested: on Linux.
2016-03-08Fix CreateString with already-encoded string or bytearray in Python 2.7.Alex Kerfoot2-4/+7
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.
2016-02-08Python: remove ctypes dependency in runtime library.rw2-4/+0
2016-01-19Merge pull request #3491 from faizanrashid/masterRobert1-2/+2
[BUG FIX] [MINOR] Fix encoding with unicode characters.
2016-01-19Revamping the FlatBuffers docs.Mark Klara1-45/+146
Adding an API reference for the supported languages. General docs cleanup, including a new `tutorial` section that supports all of the supported languages. Added samples for each supported language to mirror the new tutorial page. Cleaned up all the links by making them `@ref` style links, instead of referencing the names of the generated `.html` files. Removed all generated files that were unnecessarily committed. Also fixed the C# tests (two were failing due to a missing file). Bug: b/25801305 Tested: Tested all samples on Ubuntu, Mac, and Android. Docs were generated using doxygen and viewed on Chrome. Change-Id: I2acaba6e332a15ae2deff5f26a4a25da7bd2c954
2015-12-31[BUG FIX] [MINOR] Fix encoding with unicode characters.Faizan Rashid1-2/+2
When passing a unicode string to builder.CreateString, the default encoding assumed all characters can be encoded using ascii. Added a fix so a user can specify the encoding and how to handle errors when creating strings.
2015-12-13[BUG] [MINOR] Use buffer for specific py versionsFaizan Rashid1-1/+3
Fix for Issue 1741 Minor bug where python versions 2.7.x where x < 5 do not support unpacking from memoryview objects. Versions 2.7.5 and above will use memoryview while 2.7 versions below 2.7.5 will use buffer objects. Manual testing was performed on versions 2.7.5 and 2.7.2 to confirm both worked correctly.
2015-11-11Python: Improve Builder user interface.rw1-19/+37
+ Add state to the Builder object to track if we are inside a table, and if we are finished building the buffer. + Use this data to check that a buffer is being built correctly. + Raise an exception if a buffer is not being built correctly. + Test that the exceptions happen as expected. Based on d236dea.
2015-09-29Add self.assertNotNested() in CreateStringtguo-aa1-0/+2
And also add a test case. If you try to nest CreateString you will get a clear exception.