Skip to content

Commit

Permalink
Merge pull request #23 from Thriftpy/develop
Browse files Browse the repository at this point in the history
Release 0.4.0
  • Loading branch information
ethe committed Dec 9, 2018
2 parents 6b064cd + a7a1f0e commit 5b89e67
Show file tree
Hide file tree
Showing 105 changed files with 579 additions and 422 deletions.
17 changes: 17 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,23 @@
Changelog
=========

0.4.x
~~~~~

Version 0.4.0
-------------

Released on December 10, 2018.

Non-Backward Compatible changes:

- Rename all thriftpy to thriftpy2, via `#22`_.

- Parse thrift without sequential dependency, via `#21`_.

.. _`#22`: https://github.com/Thriftpy/thriftpy2/pull/22
.. _`#21`: https://github.com/Thriftpy/thriftpy2/pull/21

0.3.x
~~~~~

Expand Down
6 changes: 3 additions & 3 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
include README.rst CHANGES.rst
recursive-include thriftpy/protocol/cybin *.pyx *.c *.h
recursive-include thriftpy/transport *.pyx *.pxd *.c
include thriftpy/contrib/tracking/tracking.thrift
recursive-include thriftpy2/protocol/cybin *.pyx *.c *.h
recursive-include thriftpy2/transport *.pyx *.pxd *.c
include thriftpy2/contrib/tracking/tracking.thrift
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
clean:
rm -vf thriftpy/protocol/cybin/*.c thriftpy/protocol/*.so
rm -vf thriftpy/transport/*.c thriftpy/transport/*.so
rm -vf thriftpy/transport/*/*.c thriftpy/transport/*/*.so
rm -vf thriftpy2/protocol/cybin/*.c thriftpy2/protocol/*.so
rm -vf thriftpy2/transport/*.c thriftpy2/transport/*.so
rm -vf thriftpy2/transport/*/*.c thriftpy2/transport/*/*.so
rm -vf dist/*

build_ext: clean
Expand Down
42 changes: 21 additions & 21 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
========
============
ThriftPy2
========
============

.. image:: https://travis-ci.com/Thriftpy/thriftpy2.svg?branch=develop
:target: https://travis-ci.com/Thriftpy/thriftpy2

ThriftPy: https://github.com/eleme/thriftpy has deprecated, ThriftPy2 aims to provide long term support.
ThriftPy: https://github.com/eleme/thriftpy has been deprecated, ThriftPy2 aims to provide long term support.


Installation
Expand Down Expand Up @@ -42,10 +42,10 @@ Then we can make a server:

.. code:: python
import thriftpy
pingpong_thrift = thriftpy.load("pingpong.thrift", module_name="pingpong_thrift")
import thriftpy2
pingpong_thrift = thriftpy2.load("pingpong.thrift", module_name="pingpong_thrift")
from thriftpy.rpc import make_server
from thriftpy2.rpc import make_server
class Dispatcher(object):
def ping(self):
Expand All @@ -58,10 +58,10 @@ And a client:

.. code:: python
import thriftpy
pingpong_thrift = thriftpy.load("pingpong.thrift", module_name="pingpong_thrift")
import thriftpy2
pingpong_thrift = thriftpy2.load("pingpong.thrift", module_name="pingpong_thrift")
from thriftpy.rpc import make_client
from thriftpy2.rpc import make_client
client = make_client(pingpong_thrift.PingPong, '127.0.0.1', 6000)
print(client.ping())
Expand All @@ -70,12 +70,12 @@ And it also supports asyncio on Python 3.5 or later:

.. code:: python
import thriftpy
import thriftpy2
import asyncio
from thriftpy.rpc import make_aio_client
from thriftpy2.rpc import make_aio_client
echo_thrift = thriftpy.load("echo.thrift", module_name="echo_thrift")
echo_thrift = thriftpy2.load("echo.thrift", module_name="echo_thrift")
async def request():
Expand All @@ -87,11 +87,11 @@ And it also supports asyncio on Python 3.5 or later:
.. code:: python
import asyncio
import thriftpy
import thriftpy2
from thriftpy.rpc import make_aio_server
from thriftpy2.rpc import make_aio_server
echo_thrift = thriftpy.load("echo.thrift", module_name="echo_thrift")
echo_thrift = thriftpy2.load("echo.thrift", module_name="echo_thrift")
class Dispatcher(object):
Expand Down Expand Up @@ -125,11 +125,11 @@ python lib):
- Supports Python 2.7, Python 3.4+, PyPy and PyPy3.

- Pure python implementation. No longer need to compile & install the 'thrift'
package. All you need is thriftpy and thrift file.
package. All you need is thriftpy2 and thrift file.

- Compatible with Apache Thrift. You can use ThriftPy together with the
official implementation servers and clients, such as a upstream server with
a thriftpy client or the opposite.
a thriftpy2 client or the opposite.

Currently implemented protocols and transports:

Expand All @@ -152,10 +152,10 @@ python lib):
- Can directly load thrift file as module, the sdk code will be generated on
the fly.

For example, ``pingpong_thrift = thriftpy.load("pingpong.thrift", module_name="pingpong_thrift")``
For example, ``pingpong_thrift = thriftpy2.load("pingpong.thrift", module_name="pingpong_thrift")``
will load 'pingpong.thrift' as 'pingpong_thrift' module.

Or, when import hook enabled by ``thriftpy.install_import_hook()``, you can
Or, when import hook enabled by ``thriftpy2.install_import_hook()``, you can
directly use ``import pingpong_thrift`` to import the 'pingpong.thrift' file
as module, you may also use ``from pingpong_thrift import PingService`` to
import specific object from the thrift module.
Expand All @@ -179,10 +179,10 @@ Contribute
Contributors
============

https://github.com/eleme/thriftpy/graphs/contributors
https://github.com/Thriftpy/thriftpy2/graphs/contributors


Changelog
=========

https://github.com/eleme/thriftpy/blob/master/CHANGES.rst
https://github.com/Thriftpy/thriftpy2/blob/develop/CHANGES.rst
6 changes: 3 additions & 3 deletions benchmark/benchmark.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
thriftpy vs apache thrift
thriftpy2 vs apache thrift
=========================

The addressbook struct benchmark based on addressbook.thrift.
Expand Down Expand Up @@ -42,7 +42,7 @@ python2.7.6::
encode -> 0.59757399559
decode -> 0.74239397049

python3.4.1 + thriftpy::
python3.4.1 + thriftpy2::

binary protocol struct benchmark for 100000 times:
encode -> 3.291545867919922
Expand All @@ -54,7 +54,7 @@ python3.4.1 + thriftpy::

-----------------------------------

thriftpy pack benchmark:
thriftpy2 pack benchmark:

pypy2.3::

Expand Down
8 changes: 4 additions & 4 deletions benchmark/benchmark_struct.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import time

import thriftpy
from thriftpy.utils import serialize, deserialize
from thriftpy.protocol import TBinaryProtocolFactory, TCyBinaryProtocolFactory
import thriftpy2
from thriftpy2.utils import serialize, deserialize
from thriftpy2.protocol import TBinaryProtocolFactory, TCyBinaryProtocolFactory

addressbook = thriftpy.load("addressbook.thrift")
addressbook = thriftpy2.load("addressbook.thrift")


def make_addressbook():
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
('index', 'thriftpy', 'ThriftPy Documentation',
('index', 'thriftpy2', 'ThriftPy Documentation',
['Lx Yu'], 1)
]

Expand Down
58 changes: 29 additions & 29 deletions docs/index.rst
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
========
ThriftPy
ThriftPy2
========

ThriftPy is a pure python implementation of
ThriftPy2 is a pure python implementation of
`Apache Thrift <http://thrift.apache.org/>`_ in a pythonic way.

The official thrift python lib is not pythonic at all, it needs a complicated
process of installation, and the generated sdk is very ugly. Everytime the
thrift file changed you have to re-generate the sdk which causes more pain
in development.

ThriftPy helps that, it's compatible with Apache Thrift so you no longer need
ThriftPy2 helps that, it's compatible with Apache Thrift so you no longer need
to install 'thrift' package, it can import thrift file on the fly so you
no longer need to re-generate the sdk again and again and again.

Github: https://github.com/eleme/thriftpy
Github: https://github.com/Thriftpy/thriftpy2


Code Demo
=========

ThriftPy make it super easy to write server/client code with thrift. Let's
ThriftPy2 make it super easy to write server/client code with thrift. Let's
checkout this simple pingpong service demo.

We need a 'pingpong.thrift' file:
Expand All @@ -35,10 +35,10 @@ Then we can make a server:

.. code:: python
import thriftpy
pingpong_thrift = thriftpy.load("pingpong.thrift", module_name="pingpong_thrift")
import thriftpy2
pingpong_thrift = thriftpy2.load("pingpong.thrift", module_name="pingpong_thrift")
from thriftpy.rpc import make_server
from thriftpy2.rpc import make_server
class Dispatcher(object):
def ping(self):
Expand All @@ -51,10 +51,10 @@ And a client:

.. code:: python
import thriftpy
pingpong_thrift = thriftpy.load("pingpong.thrift", module_name="pingpong_thrift")
import thriftpy2
pingpong_thrift = thriftpy2.load("pingpong.thrift", module_name="pingpong_thrift")
from thriftpy.rpc import make_client
from thriftpy2.rpc import make_client
client = make_client(pingpong_thrift.PingPong, '127.0.0.1', 6000)
client.ping()
Expand All @@ -69,17 +69,17 @@ usage examples.
Features
========

Currently ThriftPy have these features (also advantages over the upstream
Currently ThriftPy2 have these features (also advantages over the upstream
python lib):

- Supports Python 2.7, Python 3.4+, PyPy and PyPy3.

- Pure python implementation. No longer need to compile & install the 'thrift'
package. All you need is thriftpy and thrift file.
package. All you need is thriftpy2 and thrift file.

- Compatible with Apache Thrift. You can use ThriftPy together with the
- Compatible with Apache Thrift. You can use ThriftPy2 together with the
official implementation servers and clients, such as a upstream server with
a thriftpy client or the opposite.
a thriftpy2 client or the opposite.

Currently implemented protocols and transports:

Expand All @@ -97,10 +97,10 @@ python lib):
- Can directly load thrift file as module, the sdk code will be generated on
the fly.

For example, ``pingpong_thrift = thriftpy.load("pingpong.thrift", module_name="pingpong_thrift")``
For example, ``pingpong_thrift = thriftpy2.load("pingpong.thrift", module_name="pingpong_thrift")``
will load 'pingpong.thrift' as 'pingpong_thrift' module.

Or, when import hook enabled by ``thriftpy.install_import_hook()``, you can
Or, when import hook enabled by ``thriftpy2.install_import_hook()``, you can
directly use ``import pingpong_thrift`` to import the 'pingpong.thrift' file
as module, you may also use ``from pingpong_thrift import PingService`` to
import specific object from the thrift module.
Expand All @@ -116,13 +116,13 @@ Install with pip.

.. code:: bash
$ pip install thriftpy
$ pip install thriftpy2
You may also install cython first to build cython extension locally.

.. code:: bash
$ pip install cython thriftpy
$ pip install cython thriftpy2
Usage Notice
Expand All @@ -139,9 +139,9 @@ the direct module.

.. code:: python
from thriftpy.protocol.binary import TBinaryProtocolFactory
from thriftpy.transport.buffered import TBufferedTransportFactory
from thriftpy.transport.framed import TFramedTransportFactory
from thriftpy2.protocol.binary import TBinaryProtocolFactory
from thriftpy2.transport.buffered import TBufferedTransportFactory
from thriftpy2.transport.framed import TFramedTransportFactory
Better Module
Expand All @@ -153,23 +153,23 @@ The direct loaded TObjects can't be pickled.

.. code:: python
>>> ab = thriftpy.load("addressbook.thrift")
>>> ab = thriftpy2.load("addressbook.thrift")
>>> pickle.dumps(ab.AddressBook())
PicklingError: Can't pickle <class 'addressbook.AddressBook'>
TObjects can be pickled when load with `module_name` provided.

.. code:: python
>>> ab = thriftpy.load("addressbook.thrift", "addressbook_thrift")
>>> ab = thriftpy2.load("addressbook.thrift", "addressbook_thrift")
>>> pickle.dumps(ab.AddressBook())
b'\x80\x03caddressbook_thrift\nAddressBook\nq\x00)\x81q\x01}q\x02X\x06\x00\x00\x00peopleq\x03Nsb.'
You can also use `from ... import ...` style after a standard module load.

.. code:: python
>>> ab = thriftpy.load("addressbook.thrift", "addressbook_thrift")
>>> ab = thriftpy2.load("addressbook.thrift", "addressbook_thrift")
>>> from addressbook_thrift import *
Expand All @@ -188,17 +188,17 @@ Some benchmark results::
encode -> 0.398949146271
decode -> 0.536000013351

# thriftpy & pypy2.3
# thriftpy2 & pypy2.3
binary protocol struct benchmark for 100000 times:
encode -> 0.413738965988
decode -> 0.605606079102

# thriftpy & py3.4
# thriftpy2 & py3.4
binary protocol struct benchmark for 100000 times:
encode -> 3.291545867919922
decode -> 4.337666034698486

# thriftpy & py3.4 + cython
# thriftpy2 & py3.4 + cython
cybin protocol struct benchmark for 100000 times:
encode -> 0.5828649997711182
decode -> 0.8259570598602295
Expand All @@ -222,7 +222,7 @@ Contribute
Contributors
============

https://github.com/eleme/thriftpy/graphs/contributors
https://github.com/Thriftpy/thriftpy2/graphs/contributors


.. include:: ../CHANGES.rst
6 changes: 3 additions & 3 deletions examples/asyncio_echo/client.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# -*- coding: utf-8 -*-
import thriftpy
import thriftpy2
import asyncio
from thriftpy.rpc import make_aio_client
from thriftpy2.rpc import make_aio_client


echo_thrift = thriftpy.load("echo.thrift", module_name="echo_thrift")
echo_thrift = thriftpy2.load("echo.thrift", module_name="echo_thrift")


async def main():
Expand Down
Loading

0 comments on commit 5b89e67

Please sign in to comment.