In [1]: %timeit 1+1
28.3 ns ± 4.08 ns per loop (mean ± std. dev. of 7 runs, 10000000 loops each)単一のステートメントの実行時間を測定する。
| import sympy | |
| # 指数部分を定義 (マイナス2分の1乗) | |
| n = -sympy.Rational(1, 2) | |
| print(n) | |
| # 8のマイナス2分の1乗を求める | |
| r = 8**n |
| import sympy | |
| # x を定義 | |
| x = sympy.Symbol('x') | |
| # 式定義 | |
| # x^3 - 2x^2 - 5x + 6 | |
| expr = x**3 - 2*(x**2) - 5*x + 6 | |
| print(expr) |
| """ | |
| Reactive Python (RxPy) のサンプル | |
| 2018/04/13:まだ途中 | |
| REFERENCES:: | |
| https://auth0.com/blog/reactive-programming-in-python/ | |
| https://github.com/ReactiveX/RxPY | |
| """ | |
| import threading |
| """ | |
| Sentry と logging の組み合わせのサンプル | |
| DSN は 環境変数 SENTRY_DSN に設定してから起動します。 | |
| (*) Windowsの場合、一時設定するには以下のようにします。 | |
| $ set SENTRY_DSN=xxxxx | |
| REFERENCES:: | |
| https://docs.python.jp/3/library/logging.config.html#logging-config-dictschema | |
| https://docs.sentry.io/clients/python/integrations/logging/ |
| { | |
| "version": 1, | |
| "disable_existing_loggers": "true", | |
| "formatters": { | |
| "console": { | |
| "format": "[%(asctime)s][%(levelname)s] %(name)s %(filename)s:%(funcName)s:%(lineno)d | %(message)s", | |
| "datefmt": "%Y/%m/%d %H:%M:%S" | |
| } | |
| }, | |
| "handlers": { |