Commit 94bae8e8 authored by Kirill Smelkov's avatar Kirill Smelkov

readme: Overhaul

Stop hiding qq and benchmarking bits in changelog only - add their
description into additional sections in readme.

Since py.bench description is now in readme, there is no need to keep
py.bench example in the changelog.
parent c859940b
......@@ -33,23 +33,6 @@ Pygolang change history
- Add `py.bench` program and `golang.testing` package with corresponding bits (commit__).
`py.bench` allows to benchmark python code similarly to `go test -bench` and `py.test`.
For example, running py.bench on the following code::
def bench_add(b):
x, y = 1, 2
for i in xrange(b.N):
x + y
gives something like::
$ py.bench --count=3 x.py
...
pymod: bench_add.py
Benchmarkadd 50000000 0.020 µs/op
Benchmarkadd 50000000 0.020 µs/op
Benchmarkadd 50000000 0.020 µs/op
__ https://lab.nexedi.com/kirr/pygolang/commit/9bf03d9c
0.0.0.dev3 (2018-07-02)
......
......@@ -2,7 +2,7 @@
Pygolang - Go-like features for Python
========================================
Package golang provides Go-like features for Python:
Package `golang` provides Go-like features for Python:
- `go` spawns lightweight thread.
- `chan` and `select` provide channels with Go semantic.
......@@ -10,6 +10,11 @@ Package golang provides Go-like features for Python:
- `defer` allows to schedule a cleanup from the main control flow.
- `gimport` allows to import python modules by full path in a Go workspace.
Additional packages and utilities are also provided__ (2__) to close other gaps
between Python and Go environments.
__ `String conversion`_
__ `Benchmarking and testing`_
Goroutines and channels
-----------------------
......@@ -115,3 +120,48 @@ will import either
- `lab.nexedi.com/kirr/go123/xnet/lonet/__init__.py`
located in `src/` under `$GOPATH`.
String conversion
-----------------
`qq` (import from `golang.gcompat`) provides `%q` functionality that quotes as
Go would do. For example the following code will print name quoted in `"`
without escaping printable UTF-8 characters::
print('hello %s' % qq(name))
`qq` accepts both `str` and `bytes` (`unicode` and `str` on Python2)
and also any other type that can be converted to `str`.
Benchmarking and testing
------------------------
`py.bench` allows to benchmark python code similarly to `go test -bench` and `py.test`.
For example, running `py.bench` on the following code::
def bench_add(b):
x, y = 1, 2
for i in xrange(b.N):
x + y
gives something like::
$ py.bench --count=3 x.py
...
pymod: bench_add.py
Benchmarkadd 50000000 0.020 µs/op
Benchmarkadd 50000000 0.020 µs/op
Benchmarkadd 50000000 0.020 µs/op
Package `golang.testing` provides corresponding runtime bits, e.g. `testing.B`.
`py.bench` produces output in `Go benchmark format`__, and so benchmark results
can be analyzed and compared with standard Go tools, for example with
`benchstat`__.
Additionally package `golang.x.perf.benchlib` can be used to load and process
such benchmarking data in Python.
__ https://github.com/golang/proposal/blob/master/design/14313-benchmark-format.md
__ https://godoc.org/golang.org/x/perf/cmd/benchstat
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