. . .
python的with与__enter__以及__exit__关系
有一些任务,可能事先需要设置,事后做清理工作。对于这种场景,Python的with语句提供了一种非常方便的处理方式。一个很好的例子是文件处理,你需要获取一个文件句柄,从文件中读取数据,然后关闭文件句柄。
. . .
Etcd安装备忘
参考
https://skyao.gitbooks.io/learning-etcd3/content/installation/linux_single.html
下载/配置
简而言之就是 : 先去 etcd 的 github找到他的release, 然后复制链接, 下载然后配置
注: 以 etcd-v3.2.1 为例,后续更新版本时可能细节有所不同。
. . .
久违pybind11
boost.python 迟暮, 久违 pybind11 , 来玩玩
官方介绍
pybind11 is a lightweight header-only library that exposes C++ types in Python and vice versa, mainly to create Python bindings of existing C++ code. Its goals and syntax are similar to the excellent Boost.Python library by David Abrahams: to minimize boilerplate code in traditional extension modules by inferring type information using compile-time introspection.
The main issue with Boost.Python—and the reason for creating such a similar project—is Boost. Boost is an enormously large and complex suite of utility libraries that works with almost every C++ compiler in existence. This compatibility has its cost: arcane template tricks and workarounds are necessary to support the oldest and buggiest of compiler specimens. Now that C++11-compatible compilers are widely available, this heavy machinery has become an excessively large and unnecessary dependency.
编写供 python 调用的 C++ 模块
下载好 pybind11 之后,我们就可以开始对着官方的 pybind11 Tutorial 进行学习了,详细的入门教程及语法请参考官方文档,这里,我们简单演示下如何编写供 python 调用的 C++ 模块.
. . .