Package: transit-python2
transit-python2Forked fromtransit-python. Python 3.6 to 3.10 are supportedTransit is a format and set of libraries for conveying values between
applications written in different programming languages. The library provides
support for marshalling data to/from Python.RationaleAPI docsMirrored for PyPISpecificationThis implementation's major.minor version number corresponds to the
version of the Transit specification it supports.NOTE: Transit is a work in progress and may evolve based on feedback.
As a result, while Transit is a great option for transferring data
between applications, it should not yet be used for storing data
durably over time. This recommendation will change when the
specification is complete.Releases and Dependency InformationThePYPIpackage istransit-python2Latest stable release:0.8You can install with any of the following:easy_install transit-python2pip install --use-wheel --pre transit-python2You can uninstall with:pip uninstall transit-python2Usage# io can be any Python file descriptor,# like you would typically use with JSON's load/dumpfromtransit.writerimportWriterfromtransit.readerimportReaderwriter=Writer(io,"json")# or "json-verbose", "msgpack"writer.write(value)reader=Reader("json")# or "msgpack"val=reader.read(io)For example:>>> from transit.writer import Writer
>>> from transit.reader import Reader
>>> from StringIO import StringIO
>>> io = StringIO()
>>> writer = Writer(io, "json")
>>> writer.write(["abc", 1234567890])
>>> s = io.getvalue()
>>> reader = Reader()
>>> vals = reader.read(StringIO(s))Supported Python versions2.7.X3.5.XType MappingTyped arrays, lists, and charsThetransit specdefines several semantic types that map to more general types in Python:typed arrays (ints, longs, doubles, floats, bools) map to Python Tupleslists map to Python Tupleschars map to Strings/UnicodeWhen the reader encounters an of these (e.g.{"ints" =>
[1,2,3]}) it delivers just the appropriate object to the app
(e.g.(1,2,3)).Use a TaggedValue to write these out if it will benefit a consuming
app e.g.:writer.write(TaggedValue("ints",[1,2,3]))Python's bool and intIn Python, bools are subclasses of int (that is,Trueis actually1).>>>hash(1)1>>>hash(True)1>>>True==1TrueThis becomes problematic when decoding a map that contains bool and
int keys.  The bool keys may be overridden (ie: you'll only see the int key),
and the value will be one of any possible bool/int keyed value.>>>{1:"Hello",True:"World"}{1:'World'}To counter this problem, the latest version of Transit Python introduces a
Boolean type with singleton (by convention of use) instances of "true" and
"false." A Boolean can be converted to a native Python bool with bool(x) where
x is the "true" or "false" instance. Logical evaluation works correctly with
Booleans (that is, they override thenonzeromethod and correctly evaluate
as true and false in simple logical evaluation), but uses of a Boolean as an
integer will fail.Default type mappingTransit typeWrite acceptsRead returnsnullNoneNonestringunicode, strunicodebooleanboolboolintegerintintdecimalfloatfloatkeywordtransit_types.Keywordtransit_types.Keywordsymboltransit_types.Symboltransit_types.Symbolbig decimalfloatfloatbig integerlonglongtimelong, int, datetimedatetimeuritransit_types.URItransit_types.URIuuiduuid.UUIDuuid.UUIDchartransit_types.TaggedValueunicodearraylist, tupletuplelistlist, tupletuplesetsetsetmapdictdictbytestransit_types.TaggedValuetupleshortstransit_types.TaggedValuetupleintstransit_types.TaggedValuetuplelongstransit_types.TaggedValuetuplefloatstransit_types.TaggedValuetupledoublestransit_types.TaggedValuetuplecharstransit_types.TaggedValuetupleboolstransit_types.TaggedValuetuplelinktransit_types.Linktransit_types.LinkDevelopmentSetupTransit Python requiresTransitto be at the same directory level as
transit-python2 for access to the exemplar files. You will also need
to add transit-python2 to your PYTHONPATH.exportPYTHONPATH=$(pwd)Tests should be run from the transit-python2 directory.Benchmarkspythontests/seattle_benchmark.pyRunning the examplespythontests/exemplars_test.pyBuildpipinstall-e.The version number is automatically incremented based on the number of commits.
The command below shows what version number will be applied.bin/revisionContributingThis library is open source, developed internally by Cognitect. We welcome discussions of potential problems and enhancement suggestions on thetransit-format mailing list. Issues can be filed using GitHubissuesfor this project. Because transit is incorporated into products and client projects, we prefer to do development internally and are not accepting pull requests or patches.Copyright and LicenseCopyright © 2014-2016 CognitectLicensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License athttp://www.apache.org/licenses/LICENSE-2.0Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.