{"id":168827,"date":"2013-02-10T11:26:03","date_gmt":"2013-02-10T07:26:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=168827"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=168827","title":{"rendered":"<span class=\"post_title\">\u041a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u044f \u0442\u0438\u043f\u043e\u0432 \u0432 Boost.Python. \u0414\u0435\u043b\u0430\u0435\u043c \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043c\u0435\u0436\u0434\u0443 \u043f\u0440\u0438\u0432\u044b\u0447\u043d\u044b\u043c\u0438 \u0442\u0438\u043f\u0430\u043c\u0438 C++ \u0438 Python<\/span>"},"content":{"rendered":"<div class=\"content html_format\">   \t\u0414\u0430\u043d\u043d\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0435\u043d\u0438\u0435\u043c \u043f\u043e\u0432\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u0438\u044f \u043e\u0431 \u043e\u0431\u0451\u0440\u0442\u043a\u0430\u0445 C++ API. \u041d\u0438\u043a\u0430\u043a\u0438\u0445 \u043e\u0431\u0451\u0440\u0442\u043e\u043a \u0441\u0435\u0433\u043e\u0434\u043d\u044f \u043d\u0435 \u0431\u0443\u0434\u0435\u0442. \u0425\u043e\u0442\u044f \u043f\u043e \u043b\u043e\u0433\u0438\u043a\u0435 \u044d\u0442\u043e \u0442\u0440\u0435\u0442\u044c\u044f \u0447\u0430\u0441\u0442\u044c <a href=\"http:\/\/habrahabr.ru\/post\/168083\/\">\u0434\u0430\u043d\u043d\u043e\u0433\u043e<\/a> <a href=\"http:\/\/habrahabr.ru\/post\/168233\/\">\u043f\u043e\u0432\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u0438\u044f<\/a>.<br \/>  \u0421\u0435\u0433\u043e\u0434\u043d\u044f \u0431\u0443\u0434\u0435\u0442 \u043c\u043e\u0440\u0435 \u043a\u0440\u043e\u0432\u0438, \u0440\u0430\u0441\u0447\u043b\u0435\u043d\u0435\u043d\u0438\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u0442\u0438\u043f\u043e\u0432 \u0438 \u043c\u0430\u0433\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0435\u043d\u0438\u0435 \u0438\u0445 \u0432 \u043f\u0440\u0438\u0432\u044b\u0447\u043d\u044b\u0435 \u0430\u043d\u0430\u043b\u043e\u0433\u0438 \u0432 \u0434\u0440\u0443\u0433\u043e\u043c \u044f\u0437\u044b\u043a\u0435.<br \/>  \u0420\u0435\u0447\u044c \u043d\u0435 \u043f\u043e\u0439\u0434\u0451\u0442 \u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0439 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u0438 \u043c\u0435\u0436\u0434\u0443 \u0441\u0442\u0440\u043e\u043a\u0430\u043c\u0438, \u043d\u0435\u0442, \u043c\u044b \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u0441\u0432\u043e\u0438 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0435\u0440\u044b.<br \/>  \u041c\u044b \u043f\u0440\u0435\u0432\u0440\u0430\u0442\u0438\u043c \u043f\u0440\u0438\u0432\u044b\u0447\u043d\u044b\u0439 <b>datetime.datetime<\/b> \u043f\u0438\u0442\u043e\u043d\u0430 \u0432 <b>boost::posix_time::ptime<\/b> \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 Boost \u0438 \u043e\u0431\u0440\u0430\u0442\u043d\u043e, \u0434\u0430 \u0447\u0451\u0440\u0442 \u0441 \u043d\u0438\u043c, \u043c\u044b \u0432\u043e\u043e\u0431\u0449\u0435 \u0432\u0441\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 datetime \u043f\u0440\u0435\u0432\u0440\u0430\u0442\u0438\u043c \u0432 \u0431\u0443\u0441\u0442\u043e\u0432\u044b\u0435 \u0442\u0438\u043f\u044b! \u0410 \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u0431\u044b\u043b\u043e \u0441\u043a\u0443\u0447\u043d\u043e, \u043f\u0440\u0438\u043d\u0435\u0441\u0451\u043c \u0432 \u0436\u0435\u0440\u0442\u0432\u0443 \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u0431\u0430\u0439\u0442 Python 3.x, \u0434\u043b\u044f \u043d\u0435\u0433\u043e \u043a\u0430\u043a \u0440\u0430\u0437 \u0435\u0449\u0451 \u043d\u0435\u0442 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0435\u0440\u0430 \u0432 Boost.Python, \u0430 \u043f\u043e\u0442\u043e\u043c \u0437\u0432\u0435\u0440\u0441\u043a\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u044e \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u0431\u0430\u0439\u0442 \u0432 \u043d\u043e\u0432\u043e\u043c \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0435\u0440\u0435 \u043f\u0438\u0442\u043e\u043d\u043e\u0432\u0441\u043a\u043e\u0433\u043e <b>uuid.UUID<\/b> \u0432 <b>boost::uuids::uuid<\/b>. \u0414\u0430, \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0435\u0440 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0435\u0440\u0435!<br \/>  \u0416\u0430\u0436\u0434\u0435\u0448\u044c \u043a\u0440\u043e\u0432\u0438, \u041a\u043e\u043b\u0438\u0437\u0435\u0439?!..<br \/>  <a name=\"habracut\"><\/a>  <\/p>\n<h4>\u0412\u043c\u0435\u0441\u0442\u043e \u0432\u0432\u0435\u0434\u0435\u043d\u0438\u044f<\/h4>\n<p>  \u0415\u0441\u043b\u0438 \u043a\u0442\u043e \u043d\u0435 \u0437\u0430\u043c\u0435\u0442\u0438\u043b, Boost.Python \u0434\u0435\u043b\u0430\u0435\u0442 \u043e\u0433\u0440\u043e\u043c\u043d\u0443\u044e \u0440\u0430\u0431\u043e\u0442\u0443, \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u044f \u043a\u0443\u0447\u0443 \u0441\u043a\u0430\u043b\u044f\u0440\u043e\u0432 \u0432 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u043a\u043b\u0430\u0441\u0441\u043e\u0432 Python \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0433\u043e \u0442\u0438\u043f\u0430. \u0415\u0441\u043b\u0438 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u0441\u0440\u0430\u0432\u043d\u0438\u0442\u044c, \u043f\u0438\u0448\u0438\u0442\u0435 \u043d\u0430 \u0447\u0438\u0441\u0442\u043e\u043c \u0421\u0438, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e C-API, \u0434\u0430\u0439\u0442\u0435 \u0435\u043c\u0443 \u043f\u043e\u0441\u043d\u043e\u0448\u0430\u0442\u044c \u0441\u0432\u043e\u0439 \u043c\u043e\u0437\u0433. \u041f\u043e\u0442\u0440\u0430\u0442\u044c\u0442\u0435 \u043a\u0443\u0447\u0443 \u0432\u0440\u0435\u043c\u0435\u043d\u0438, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043d\u044f\u0442\u044c \u043a\u043e\u043c\u0444\u043e\u0440\u0442 \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0439, \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u043e \u043c\u044f\u0433\u043a\u043e\u0433\u043e \u043a\u0440\u0435\u0441\u043b\u0430, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u0433\u043e\u0440\u044f\u0447\u0435\u0439 \u0432\u0430\u043d\u043d\u043e\u0439 \u0438 \u043f\u0443\u043b\u044c\u0442\u0430 \u0434\u0438\u0441\u0442\u0430\u043d\u0446\u0438\u043e\u043d\u043d\u043e\u0433\u043e \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u0442\u0435\u043b\u0435\u0432\u0438\u0437\u043e\u0440\u0430. \u041b\u044e\u0431\u0438\u0442\u0435\u043b\u0438 \u0434\u0435\u0440\u0435\u0432\u044f\u043d\u043d\u044b\u0445 \u043b\u0430\u0432\u043e\u043a, \u043c\u044b\u0442\u044c\u044f \u0432 \u043f\u0440\u043e\u0440\u0443\u0431\u0438 \u0438 \u043b\u0443\u0447\u0438\u043d\u044b, \u043f\u0443\u0441\u0442\u044c \u0438 \u0434\u0430\u043b\u044c\u0448\u0435 \u0437\u0430\u043d\u0438\u043c\u0430\u044e\u0442\u0441\u044f \u043b\u0443\u0431\u043e\u0447\u043d\u044b\u043c \u0442\u0432\u043e\u0440\u0447\u0435\u0441\u0442\u0432\u043e\u043c.<br \/>  \u0422\u0430\u043a \u0432\u043e\u0442, \u0435\u0441\u0442\u044c \u0442\u0430\u043a\u043e\u0435 \u043f\u043e\u043d\u044f\u0442\u0438\u0435: built-in converters \u0432 Boost.Python \u2014 \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0435 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0435\u0440\u044b \u0442\u0438\u043f\u043e\u0432 \u0438\u0437 Python \u0432 C++ \u0438 \u043e\u0431\u0440\u0430\u0442\u043d\u043e, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0447\u0430\u0441\u0442\u0438\u0447\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u044b \u0432 $(BoostPath)\\libs\\python\\src\\converter \u0438 $(BoostPath)\\boost\\python\\converter. \u0418\u0445 \u043c\u043d\u043e\u0433\u043e, \u043e\u043d\u0438 \u0440\u0435\u0448\u0430\u044e\u0442 \u0433\u0434\u0435-\u0442\u043e \u043e\u043a\u043e\u043b\u043e 95% \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441\u043e \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u043c\u0438 \u0442\u0438\u043f\u0430\u043c\u0438 Python \u0438 C++, \u0435\u0441\u0442\u044c \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u044f \u0441\u0442\u0440\u043e\u043a, <a href=\"http:\/\/habrahabr.ru\/post\/161931\/\">\u043d\u0435 \u0438\u0434\u0435\u0430\u043b\u044c\u043d\u0430\u044f \u043a\u043e\u043d\u0435\u0447\u043d\u043e<\/a>, \u043d\u043e \u0435\u0441\u043b\u0438 \u0432 C++ \u043c\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u043c \u0441 UTF-8 \u0441\u0442\u0440\u043e\u043a\u0430\u043c\u0438 \u0438\u043b\u0438 wide-\u0441\u0442\u0440\u043e\u043a\u0430\u043c\u0438, \u0442\u043e \u0432\u0441\u0451 \u0431\u0443\u0434\u0435\u0442 \u0431\u044b\u0441\u0442\u0440\u043e, \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0438 \u043d\u0435\u0437\u0430\u043c\u0435\u0442\u043d\u043e, \u0432 \u0441\u043c\u044b\u0441\u043b\u0435 \u0443\u0434\u043e\u0431\u043d\u043e \u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438.<br \/>  \u041f\u043e\u0447\u0442\u0438 \u0432\u0441\u0451 \u0447\u0442\u043e \u043d\u0435 \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u043c\u0438 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0435\u0440\u0430\u043c\u0438, \u0440\u0435\u0448\u0430\u0435\u0442\u0441\u044f \u043e\u0431\u0451\u0440\u0442\u043a\u0430\u043c\u0438 \u0432\u0430\u0448\u0438\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432. Boost.Python \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442 \u043f\u043e\u0438\u0441\u0442\u0438\u043d\u0435 \u0447\u0443\u0434\u043e\u0432\u0438\u0449\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u043f\u0443\u0442\u044c, \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u043e\u0431\u0451\u0440\u0442\u043a\u0438 \u043a\u043b\u0430\u0441\u0441\u043e\u0432, \u0432 \u0432\u0438\u0434\u0435 \u043c\u0435\u0442\u0430-\u044f\u0437\u044b\u043a\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0434\u0430\u0436\u0435 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043a\u0430\u043a \u043a\u043b\u0430\u0441\u0441 Python:  <\/p>\n<pre><code class=\"cpp\">class_&lt;Some&gt;( &quot;Some&quot; )     .def( &quot;method_A&quot;, &Some::method_A, args( &quot;x&quot;, &quot;y&quot;, &quot;z&quot; ) )     .def( &quot;method_B&quot;, &Some::method_B, agrs( &quot;u&quot;, &quot;v&quot; ) ) ; <\/code><\/pre>\n<p>  \u0412\u0441\u0451 \u0437\u0434\u043e\u0440\u043e\u0432\u043e, \u043d\u043e \u0435\u0441\u0442\u044c \u043e\u0434\u043d\u043e \u043d\u043e\u2026<br \/>  \u2026 \u043e\u0434\u043d\u043e \u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u0438 \u0437\u0430\u043c\u0435\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u043d\u043e: \u0438 C++, \u0438 Python \u2014 \u044f\u0437\u044b\u043a\u0438 \u0441\u043e \u0441\u0432\u043e\u0438\u043c\u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430\u043c\u0438. \u0412 C++   <\/p>\n<pre><code class=\"cpp\">#include &lt;boost\/date_time.hpp&gt; #include &lt;boost\/uuid\/uuid.hpp&gt; <\/code><\/pre>\n<p>  \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0434\u0435-\u0444\u0430\u043a\u0442\u043e \u0430\u043d\u0430\u043b\u043e\u0433\u043e\u043c \u0432 Python:  <\/p>\n<pre><code class=\"python\">import datetime import uuid <\/code><\/pre>\n<p>  \u0422\u0430\u043a \u0432\u043e\u0442, \u043e\u0447\u0435\u043d\u044c \u043c\u043d\u043e\u0433\u043e\u0435 \u0432 \u0432\u0430\u0448\u0435\u043c C++ \u043a\u043e\u0434\u0435 \u0443\u0436\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0437\u0430\u0432\u044f\u0437\u0430\u043d\u043e \u0438\u043c\u0435\u043d\u043d\u043e \u043d\u0430 \u0440\u0430\u0431\u043e\u0442\u0443 \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0441 \u043a\u043b\u0430\u0441\u0441\u043e\u043c <b>boost::gregorian::date<\/b>, \u0430 \u0432 Python \u0432 \u0441\u0432\u043e\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u043c\u043d\u043e\u0433\u043e\u0435 \u0437\u0430\u0432\u044f\u0437\u0430\u043d\u043e \u043d\u0430 \u043a\u043b\u0430\u0441\u0441 <b>datetime.date<\/b>, \u0435\u0433\u043e \u0430\u043d\u0430\u043b\u043e\u0433. \u0420\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0432 Python \u0441 \u043e\u0431\u0451\u0440\u0442\u043a\u043e\u0439 \u043a\u043b\u0430\u0441\u0441\u0430 <b>boost::gregorian::date<\/b>, \u043e\u0431\u0451\u0440\u043d\u0443\u0442\u043e\u043c\u0443 \u0441\u043e \u0432\u0441\u0435\u043c\u0438 \u043c\u0435\u0442\u043e\u0434\u0430\u043c\u0438, \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u043e\u0439 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u043e\u0432 \u0438 \u043f\u043e\u043f\u044b\u0442\u043a\u0430 \u0432\u043e\u0442\u043a\u043d\u0443\u0442\u044c \u0435\u0433\u043e \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u044b \u0432\u043c\u0435\u0441\u0442\u043e \u043f\u0440\u0438\u0432\u044b\u0447\u043d\u043e\u0433\u043e <b>datetime.date<\/b> \u2014 \u044d\u0442\u043e \u044f \u0434\u0430\u0436\u0435 \u043d\u0435 \u0437\u043d\u0430\u044e \u043a\u0430\u043a \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f, \u044d\u0442\u043e \u043d\u0435 \u043a\u043e\u0441\u0442\u044b\u043b\u044c, \u044d\u0442\u043e \u0442\u0430\u043d\u0446\u044b \u0441 \u0433\u0440\u0430\u043d\u0430\u0442\u043e\u0439. \u0418 \u044d\u0442\u0430 \u0433\u0440\u0430\u043d\u0430\u0442\u0430 \u0440\u0432\u0430\u043d\u0451\u0442, \u0433\u043e\u0441\u043f\u043e\u0434\u0430 \u043f\u0440\u0438\u0441\u044f\u0436\u043d\u044b\u0435 \u0437\u0430\u0441\u0435\u0434\u0430\u0442\u0435\u043b\u0438. \u041d\u0430 \u0441\u0442\u043e\u0440\u043e\u043d\u0435 Python \u043d\u0443\u0436\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441\u043e \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u043e\u0439 \u0434\u0430\u0442\u044b \u0438 \u0432\u0440\u0435\u043c\u0435\u043d\u0438.<br \/>  \u0415\u0441\u043b\u0438 \u0432\u044b \u0447\u0438\u0442\u0430\u0435\u0442\u0435 \u044d\u0442\u043e, \u0438 \u0441\u043c\u043e\u0442\u0440\u0438\u0442\u0435 \u043d\u0430 \u0441\u0432\u043e\u0439 \u043a\u043e\u0434, \u0433\u0434\u0435 \u0432\u044b \u0447\u0435\u0440\u0435\u0437 extract \u0434\u043e\u0441\u0442\u0430\u0451\u0442\u0435 \u0432 C++ \u043f\u043e\u043b\u044f \u043f\u0438\u0442\u043e\u043d\u043e\u0432\u0441\u043a\u043e\u0433\u043e datetime, \u0442\u043e \u043d\u0435\u0447\u0435\u0433\u043e \u0433\u043b\u0443\u043f\u043e \u0443\u043b\u044b\u0431\u0430\u0442\u044c\u0441\u044f, \u0432\u0441\u0451 \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0435 \u0430\u0431\u0437\u0430\u0446\u0435\u043c \u0432\u044b\u0448\u0435 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0441\u044f \u043a \u0432\u0430\u043c \u0432 \u043d\u0435 \u043c\u0435\u043d\u044c\u0448\u0435 \u0441\u0442\u0435\u043f\u0435\u043d\u0438. \u0414\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u0432 C++ \u0441\u0432\u043e\u0439 \u043c\u0435\u0433\u0430-\u043a\u043b\u0430\u0441\u0441 \u0434\u0430\u0442\u044b\/\u0432\u0440\u0435\u043c\u0435\u043d\u0438, \u0442\u043e \u043b\u0443\u0447\u0448\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0435\u0440 \u0442\u0438\u043f\u0430, \u0447\u0435\u043c \u0432\u044b\u0446\u0435\u043f\u043b\u044f\u0442\u044c \u0438\u0445 \u043f\u043e \u043e\u0434\u043d\u043e\u043c\u0443 \u043f\u043e\u043b\u044e \u0432 \u043a\u0430\u043a\u043e\u043c-\u0442\u043e \u0432\u0435\u043b\u043e\u0441\u0438\u043f\u0435\u0434\u043d\u043e\u043c \u043c\u0435\u0442\u043e\u0434\u0435.<br \/>  \u0412 \u043e\u0431\u0449\u0435\u043c, \u0435\u0441\u043b\u0438 \u043d\u0430 \u0441\u0442\u043e\u0440\u043e\u043d\u0435 Python \u0441\u0432\u043e\u0439 \u0442\u0438\u043f, \u0430 \u043d\u0430 \u0441\u0442\u043e\u0440\u043e\u043d\u0435 \u0421++ \u0441\u0432\u043e\u0439 \u0443\u0441\u0442\u043e\u044f\u0432\u0448\u0438\u0439\u0441\u044f \u0442\u0438\u043f, \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0449\u0438\u0439 \u0431\u0430\u0437\u043e\u0432\u0443\u044e \u043b\u043e\u0433\u0438\u043a\u0443 \u0441 \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0435\u0439, \u0442\u043e \u0432\u0430\u043c \u043d\u0443\u0436\u0435\u043d \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0435\u0440.<br \/>  \u0412\u0430\u043c \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u0443\u0436\u0435\u043d \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0435\u0440.<\/p>\n<h4>\u0427\u0442\u043e \u0442\u0430\u043a\u043e\u0435 \u0435\u0441\u0442\u044c \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0435\u0440<\/h4>\n<p>  \u041a\u043e\u043d\u0432\u0435\u0440\u0442\u0435\u0440 \u2014 \u044d\u0442\u043e \u043d\u0435\u043a\u043e\u0435 \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0435 \u0432 Boost.Python \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0438\u0437 \u0442\u0438\u043f\u0430 C++ \u0432 \u0442\u0438\u043f Python \u0438\u043b\u0438 \u043e\u0431\u0440\u0430\u0442\u043d\u043e. \u041d\u0430 \u0441\u0442\u043e\u0440\u043e\u043d\u0435 C++ \u0432\u044b \u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0435\u0441\u044c \u043f\u0440\u0438\u0432\u044b\u0447\u043d\u044b\u043c\u0438 \u0442\u0438\u043f\u0430\u043c\u0438, \u0432 \u043f\u043e\u043b\u043d\u043e\u0439 \u0443\u0432\u0435\u0440\u0435\u043d\u043d\u043e\u0441\u0442\u0438, \u0447\u0442\u043e \u0432 Python \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u0442\u0438\u043f. \u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0435\u0440\u044b \u043e\u0431\u044b\u0447\u043d\u043e \u043f\u0438\u0448\u0443\u0442 \u0432 \u043e\u0431\u0435 \u0441\u0442\u043e\u0440\u043e\u043d\u044b, \u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0438\u0437 C++ \u0432 Python \u043d\u0430 \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u043f\u0440\u043e\u0449\u0435, \u0441\u0430\u043c\u0438 \u0443\u0432\u0438\u0434\u0438\u0442\u0435. \u0412\u0441\u0451 \u0434\u0435\u043b\u043e \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430 \u0432 C++ \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u043f\u0430\u043c\u044f\u0442\u0438, \u0447\u0442\u043e \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0437\u0430\u0447\u0430\u0441\u0442\u0443\u044e \u043d\u0435\u0442\u0440\u0435\u0432\u0438\u0430\u043b\u044c\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435\u0439. \u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0432 Python \u0437\u0430\u0434\u0430\u0447\u0430 \u043a\u0440\u0430\u0439\u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u0430\u044f, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0430\u0447\u043d\u0451\u043c \u0441 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0438\u0437 C++ \u0432 Python.<\/p>\n<h4>\u041a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u044f \u0442\u0438\u043f\u0430 \u0438\u0437 C++ \u0432 Python<\/h4>\n<p>  \u0414\u043b\u044f \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u0438 \u0438\u0437 C++ \u0432 Python \u0432\u0430\u043c \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0443 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0435\u0441\u0442\u044c \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043c\u0435\u0442\u043e\u0434 <b>convert<\/b>, \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u044e\u0449\u0438\u0439 \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u0442\u0438\u043f \u0432 C++ \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0449\u0438\u0439 <b>PyObject<\/b>*, \u043e\u0431\u0449\u0438\u0439 \u0442\u0438\u043f \u0434\u043b\u044f \u043b\u044e\u0431\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0449\u0435\u0433\u043e\u0441\u044f \u0432 C-API \u044f\u0437\u044b\u043a\u0430 Python \u0438 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043d\u0430\u0447\u0438\u043d\u043a\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 boost::python::object.<br \/>  \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u0440\u0430\u0437\u0443 \u0437\u0430\u0432\u0435\u0434\u0451\u043c \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u0443\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043c\u0430\u0441\u0441\u043e\u0432\u043e\u0439 \u0431\u043e\u0439\u043d\u0438:  <\/p>\n<pre><code class=\"cpp\">template&lt; typename T &gt; struct type_into_python {     static PyObject* convert( T const& ); }; <\/code><\/pre>\n<p>  \u0412\u0441\u0451 \u0447\u0442\u043e \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u2014 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0434\u043b\u044f \u0442\u0438\u043f\u0430 boost::posix_time::ptime \u043c\u0435\u0442\u043e\u0434 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u043e\u0439 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b:  <\/p>\n<pre><code class=\"cpp\">template&lt;&gt; PyObject* type_into_python&lt;ptime&gt;::convert( ptime const& );  <\/code><\/pre>\n<p>  \u0438 \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0435\u0440 \u043f\u0440\u0438 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0438 \u043c\u043e\u0434\u0443\u043b\u044f \u0432\u043d\u0443\u0442\u0440\u0438 <b>BOOST_PYTHON_MODULE<\/b>:  <\/p>\n<pre><code class=\"cpp\">    to_python_converter&lt; ptime, type_into_python&lt;ptime&gt; &gt;(); <\/code><\/pre>\n<p>  \u041d\u0443 \u0445\u043e\u0440\u043e\u0448\u043e, \u0440\u0430\u0437 \u0443\u0436 \u044f \u0441\u043a\u0430\u0437\u0430\u043b \u0410\u0437, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u043a\u0430\u0436\u0443 \u0432\u0430\u043c \u0438 \u0411\u0443\u043a\u0438. \u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0435\u0440\u0430 \u0434\u043b\u044f boost::posix_time::ptime \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u043f\u0440\u0438\u0431\u043b\u0438\u0437\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0432\u043e\u0442 \u0442\u0430\u043a:  <\/p>\n<pre><code class=\"cpp\">PyObject* type_into_python&lt;ptime&gt;::convert( ptime const& t ) {     auto d = t.date();     auto tod = t.time_of_day();     auto usec = tod.total_microseconds() % 1000000;     return PyDateTime_FromDateAndTime( d.year(), d.month(), d.day(), tod.hours(), tod.minutes(), tod.seconds(), usec ); } <\/code><\/pre>\n<p>  <b>\u0412\u0430\u0436\u043d\u043e!<\/b> \u041f\u0440\u0438 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u043c\u043e\u0434\u0443\u043b\u044f \u043d\u0430\u043c \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u0443\u0436\u043d\u043e <u>\u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c<\/u> <b>datetime<\/b> \u0447\u0435\u0440\u0435\u0437 C-API:  <\/p>\n<pre><code class=\"cpp\">    PyDateTime_IMPORT;     to_python_converter&lt; ptime, type_into_python&lt;ptime&gt; &gt;(); <\/code><\/pre>\n<p>  \u0411\u0435\u0437 \u0441\u0442\u0440\u043e\u043a\u0438 <b>PyDateTime_IMPORT<\/b> \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0432\u0437\u043b\u0435\u0442\u0438\u0442.<\/p>\n<p>  \u041d\u0430\u043c \u0432 \u043e\u0431\u0449\u0435\u043c \u043f\u043e\u0432\u0435\u0437\u043b\u043e \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0432 C-API \u044f\u0437\u044b\u043a\u0430 Python \u0435\u0441\u0442\u044c \u0433\u043e\u0442\u043e\u0432\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044e PyObject* \u043d\u0430 \u043d\u043e\u0432\u044b\u0439 <b>datetime.datetime<\/b> \u043f\u043e \u0435\u0433\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c, \u043f\u043e \u0441\u0443\u0442\u0438 \u0430\u043d\u0430\u043b\u043e\u0433 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430 \u043a\u043b\u0430\u0441\u0441\u0430 datetime. \u0418 \u043d\u0435 \u043f\u043e\u0432\u0435\u0437\u043b\u043e, \u0447\u0442\u043e \u0432 Boost \u0442\u0430\u043a\u043e\u0435 \u00ab\u0437\u0430\u0431\u0430\u0432\u043d\u043e\u0435\u00bb API \u0434\u043b\u044f \u043a\u043b\u0430\u0441\u0441\u0430 <b>ptime<\/b>. \u041a\u043b\u0430\u0441\u0441 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0441\u044f \u043d\u0435 \u0441\u043e\u0432\u0441\u0435\u043c \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u044b\u043c, \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432\u044b\u0446\u0435\u043f\u043b\u044f\u0442\u044c \u0438\u0437 \u043d\u0435\u0433\u043e \u0434\u0430\u0442\u0443 \u0438 \u0432\u0440\u0435\u043c\u044f, \u043d\u0430\u0445\u043e\u0434\u044f\u0449\u0438\u0435\u0441\u044f \u0442\u0430\u043c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u043c\u0438 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430\u043c\u0438, \u043f\u0440\u0438\u0447\u0451\u043c \u0432\u0440\u0435\u043c\u044f \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043e \u0432 \u0432\u0438\u0434\u0435 <b>time_duration<\/b> \u2014 \u0430\u043d\u0430\u043b\u043e\u0433 \u043d\u0435 \u0441\u0442\u043e\u043b\u044c\u043a\u043e datetime.time, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u043a\u043e\u0440\u0435\u0435 datetime.timedelta! \u042d\u0442\u043e \u0432 \u043e\u0431\u0449\u0435\u043c-\u0442\u043e \u043d\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u0432\u0437\u0430\u0438\u043c\u043e\u043e\u0434\u043d\u043e\u0437\u043d\u0430\u0447\u043d\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0442\u0438\u043f\u044b \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 datetime \u0432 C++.\u041d\u0443 \u0438 \u0441\u043e\u0432\u0441\u0435\u043c \u043d\u0435\u043f\u0440\u0438\u044f\u0442\u043d\u043e \u0442\u043e, \u0447\u0442\u043e <b>boost::posix_time::time_duration<\/b> \u043d\u0435 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043f\u0440\u044f\u043c\u043e\u0433\u043e \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u043c\u0438\u043a\u0440\u043e\u0441\u0435\u043a\u0443\u043d\u0434\u0430\u043c \u0438 \u043c\u0438\u043b\u043b\u0438\u0441\u0435\u043a\u0443\u043d\u0434\u0430\u043c. \u0412\u043c\u0435\u0441\u0442\u043e \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043b\u0438\u0431\u043e \u00ab\u0445\u0438\u0442\u0440\u043e\u00bb \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u043c\u0435\u0442\u043e\u0434\u043e\u043c fractional_seconds(), \u043b\u0438\u0431\u043e \u0442\u0443\u043f\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441\u0442\u0440\u0430\u0448\u043d\u043e\u0435 \u2014 \u0432\u0437\u044f\u0442\u044c \u043c\u043e\u0434\u0443\u043b\u044c total_microseconds() % 1000000. \u0427\u0442\u043e \u0445\u0443\u0436\u0435 \u2014 \u044f \u0435\u0449\u0451 \u043d\u0435 \u0440\u0435\u0448\u0438\u043b, \u043c\u043d\u0435 \u0432\u043e\u043e\u0431\u0449\u0435 \u043d\u0435 \u043d\u0440\u0430\u0432\u0438\u0442\u0441\u044f \u043a\u0430\u043a \u0441\u0434\u0435\u043b\u0430\u043d <b>time_duration<\/b>. \u041c\u044b \u0438\u0437 \u043d\u0435\u0433\u043e \u0437\u0430 \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u043a\u043b\u0430\u0441\u0441 datetime.time, \u0430 \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u0445\u043e\u0436\u0438\u0439 \u043a\u043b\u0430\u0441\u0441 datetime.timedelta \u043c\u044b \u043f\u043e\u043a\u0430 \u0442\u0440\u043e\u0433\u0430\u0442\u044c \u043d\u0435 \u0431\u0443\u0434\u0435\u043c.<\/p>\n<h4>\u041a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u044f \u0438\u0437 Python \u0432 C++<\/h4>\n<p>  \u0425\u0435-\u0445\u0435, \u0434\u0440\u0443\u0437\u044c\u044f \u043c\u043e\u0438, \u044d\u0442\u043e \u0440\u0435\u0430\u043b\u044c\u043d\u043e \u0441\u043b\u043e\u0436\u043d\u044b\u0439 \u043f\u0443\u043d\u043a\u0442. \u0417\u0430\u043f\u0430\u0441\u0438\u0442\u0435\u0441\u044c \u0432\u0430\u043b\u0438\u0434\u043e\u043b\u043e\u043c, \u043f\u0440\u0438\u0441\u0442\u0435\u0433\u043d\u0438\u0442\u0435 \u0440\u0435\u043c\u043d\u0438.<br \/>  \u0412\u0441\u0451 \u0432\u0440\u043e\u0434\u0435 \u0431\u044b \u0442\u043e\u0447\u043d\u043e \u0442\u0430\u043a \u0436\u0435: \u0434\u0435\u043b\u0430\u0435\u043c \u0448\u0430\u0431\u043b\u043e\u043d \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0441 \u0434\u0432\u0443\u043c\u044f \u043c\u0435\u0442\u043e\u0434\u0430\u043c\u0438 convertible \u0438 construct \u2014 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u0438 \u0438 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u0442\u0438\u043f\u0430 \u0432 C++. \u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0432\u0441\u0451 \u0440\u0430\u0432\u043d\u043e \u043a\u0430\u043a \u043d\u0430\u0437\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u043c\u0435\u0442\u043e\u0434\u044b, \u0433\u043b\u0430\u0432\u043d\u043e\u0435 \u0441\u043e\u0441\u043b\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u043d\u0438\u0445 \u043f\u0440\u0438 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438, \u0443\u0434\u043e\u0431\u043d\u0435\u0435 \u0432\u0441\u0435\u0433\u043e \u044d\u0442\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u0432 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0435 \u043d\u0430\u0448\u0435\u0439 \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u043e\u0439 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b:  <\/p>\n<pre><code class=\"cpp\">template&lt; typename T &gt; struct type_from_python {     type_from_python()     {         converter::registry::push_back( convertible, construct, type_id&lt;T&gt;() );     }      static void* convertible( PyObject* );     static void construct( PyObject*, converter::rvalue_from_python_stage1_data* ); }; <\/code><\/pre>\n<p>  \u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043f\u0440\u0438 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0438 \u043c\u043e\u0434\u0443\u043b\u044f \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b. \u041d\u0443 \u0438, \u0440\u0430\u0437\u0443\u043c\u0435\u0435\u0442\u0441\u044f, \u043d\u0443\u0436\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u0443\u0435\u043c\u043e\u0433\u043e \u0442\u0438\u043f\u0430, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0434\u043b\u044f ptime:  <\/p>\n<pre><code class=\"cpp\">template&lt;&gt; void* type_from_python&lt;ptime&gt;::convertible( PyObject* ); template&lt;&gt; void  type_from_python&lt;ptime&gt;::construct( PyObject*, converter::rvalue_from_python_stage1_data* ); <\/code><\/pre>\n<p>  \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0441\u0440\u0430\u0437\u0443 \u043d\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u043c\u0435\u0442\u043e\u0434\u0430 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043d\u0430 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0431\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0438 \u043c\u0435\u0442\u043e\u0434\u0430 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f ptime:  <\/p>\n<pre><code class=\"cpp\">void* type_from_python&lt;ptime&gt;::convertible( PyObject* obj ) {     return PyDateTime_Check( obj ) ? obj : nullptr; }  void type_from_python&lt;ptime&gt;::construct( PyObject* obj, converter::rvalue_from_python_stage1_data* data ) {     auto storage = reinterpret_cast&lt; converter::rvalue_from_python_storage&lt;ptime&gt;* &gt;( data )-&gt;storage.bytes;     date date_only( PyDateTime_GET_YEAR( obj ), PyDateTime_GET_MONTH( obj ), PyDateTime_GET_DAY( obj ) );     time_duration time_of_day( PyDateTime_DATE_GET_HOUR( obj ), PyDateTime_DATE_GET_MINUTE( obj ), PyDateTime_DATE_GET_SECOND( obj ) );     time_of_day += microsec( PyDateTime_DATE_GET_MICROSECOND( obj ) );     new(storage) ptime( date_only, time_of_day );     data-&gt;convertible = storage;  } <\/code><\/pre>\n<p>  \u0421 \u043c\u0435\u0442\u043e\u0434\u043e\u043c <b>convertible<\/b> \u0432\u0441\u0451 \u044f\u0441\u043d\u043e: \u0442\u044b <b>datetime<\/b> \u2014 \u043f\u0440\u043e\u0445\u043e\u0434\u0438, \u043d\u0435\u0442 \u2014 <b>nullptr<\/b> \u0438 \u043d\u0430 \u0432\u044b\u0445\u043e\u0434.<br \/>  \u0410 \u0432\u043e\u0442 \u043c\u0435\u0442\u043e\u0434 <b>construct<\/b> \u0431\u0443\u0434\u0435\u0442 \u0442\u0430\u043a\u0438\u043c \u0436\u0435 \u0437\u0443\u0431\u043e\u0434\u0440\u043e\u0431\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c \u0434\u043b\u044f \u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u043e <u>\u043a\u0430\u0436\u0434\u043e\u0433\u043e<\/u> \u0442\u0438\u043f\u0430!<br \/>  \u0414\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u0441\u0432\u043e\u0439 \u0442\u0438\u043f MyDateTime, \u0432\u0430\u043c <u>\u043f\u0440\u0438\u0434\u0451\u0442\u0441\u044f<\/u> \u0435\u0433\u043e \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043f\u043e \u043c\u0435\u0441\u0442\u0443 \u0447\u0435\u0440\u0435\u0437 <b>\u0440\u0430\u0437\u043c\u0435\u0449\u0430\u044e\u0449\u0438\u0439 new<\/b> \u0442\u0430\u043c, \u0433\u0434\u0435 \u0432\u0430\u043c \u0434\u0430\u0434\u0443\u0442 \u0435\u0433\u043e \u0440\u0430\u0437\u043c\u0435\u0441\u0442\u0438\u0442\u044c! \u0412\u0438\u0434\u0438\u0442\u0435 \u0432\u043e\u0442 \u044d\u0442\u043e\u0442 \u0437\u0430\u0431\u0430\u0432\u043d\u044b\u0439 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440:  <\/p>\n<pre><code class=\"cpp\">    new(storage) ptime( date_only, time_of_day ); <\/code><\/pre>\n<p>  \u042d\u0442\u043e \u0440\u0430\u0437\u043c\u0435\u0449\u0430\u044e\u0449\u0438\u0439 new. \u041e\u043d \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u0432\u0430\u0448 \u043d\u043e\u0432\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 \u0432 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u043c \u043c\u0435\u0441\u0442\u0435. \u042d\u0442\u043e \u0441\u0430\u043c\u043e\u0435 \u043c\u0435\u0441\u0442\u043e \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0435\u0449\u0451 \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u044c, \u043d\u0430\u043c \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043f\u0443\u0442\u044c \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0438\u0441\u043a\u043e\u043c\u043e\u0433\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044f:  <\/p>\n<pre><code class=\"cpp\">    auto storage = reinterpret_cast&lt; converter::rvalue_from_python_storage&lt;ptime&gt;* &gt;( data )-&gt;storage.bytes; <\/code><\/pre>\n<p>  \u042f \u043d\u0435 \u0431\u0443\u0434\u0443 \u044d\u0442\u043e \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c. \u041f\u0440\u043e\u0441\u0442\u043e \u0437\u0430\u043f\u043e\u043c\u043d\u0438\u0442\u0435.<br \/>  \u0412\u0441\u0451 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0435 \u2014 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u0432\u044b\u0437\u043e\u0432\u0430 \u0432\u043f\u043e\u043b\u043d\u0435 \u043f\u043e\u043d\u044f\u0442\u043d\u043e\u0433\u043e \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430 \u043d\u0435\u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 ptime.<br \/>  \u041d\u0435 \u0437\u0430\u0431\u0443\u0434\u044c\u0442\u0435 \u0432 \u043a\u043e\u043d\u0446\u0435 \u0437\u0430\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0435\u0449\u0451 \u043e\u0434\u043d\u043e \u043f\u043e\u043b\u0435:  <\/p>\n<pre><code class=\"cpp\">    data-&gt;convertible = storage; <\/code><\/pre>\n<p>  \u041e\u043f\u044f\u0442\u044c \u0436\u0435 \u043d\u0435 \u0437\u043d\u0430\u044e \u043a\u0430\u043a \u044d\u0442\u043e \u043f\u043e\u043c\u044f\u0433\u0447\u0435 \u043d\u0430\u0437\u0432\u0430\u0442\u044c, \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u043e\u043c\u043d\u0438\u0442\u0435, \u0447\u0442\u043e \u044d\u0442\u043e \u0432\u0430\u0436\u043d\u043e \u0438 \u043f\u043e\u043b\u0435 \u043d\u0443\u0436\u043d\u043e \u0437\u0430\u043f\u043e\u043b\u043d\u0438\u0442\u044c. \u0414\u0443\u043c\u0430\u0439\u0442\u0435 \u043e\u0431 \u044d\u0442\u043e\u043c \u043a\u0430\u043a \u043e \u043d\u0435\u043f\u0440\u0438\u044f\u0442\u043d\u043e\u0439 \u043c\u0435\u043b\u043e\u0447\u0438 \u043f\u0435\u0440\u0435\u0434 \u0432\u0441\u0435\u043e\u0431\u0449\u0438\u043c \u0441\u0447\u0430\u0441\u0442\u044c\u0435\u043c.<br \/>  \u041f\u0440\u0438\u043c\u0435\u0440\u044b \u043a\u0430\u043a \u044d\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442 \u043a\u0442\u043e-\u0442\u043e \u043a\u0440\u043e\u043c\u0435 \u043c\u0435\u043d\u044f \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c <a href=\"http:\/\/misspent.wordpress.com\/2009\/09\/27\/how-to-write-boost-python-converters\/\">\u0437\u0434\u0435\u0441\u044c<\/a>, <a href=\"http:\/\/code.activestate.com\/lists\/python-cplusplus-sig\/16463\/\">\u0437\u0434\u0435\u0441\u044c<\/a> \u0438 <a href=\"http:\/\/www.boost.org\/doc\/libs\/1_39_0\/libs\/python\/doc\/v2\/faq.html#custom_string\">\u0437\u0434\u0435\u0441\u044c \u043d\u0430 \u0441\u0430\u0439\u0442\u0435 Boost.Python \u0432 \u0440\u0430\u0437\u0434\u0435\u043b\u0435 FAQ<\/a>.<\/p>\n<h4>\u041f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0442\u0438\u043f\u043e\u0432 datetime \u0432 &lt;boost\/date_time.hpp&gt; \u0438 \u043e\u0431\u0440\u0430\u0442\u043d\u043e<\/h4>\n<p>  \u0418\u0442\u043e\u0433\u043e, \u0434\u043b\u044f date \u0438 time \u043f\u043e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0432\u0441\u0451 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e. \u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u043d\u0430\u0448\u0435\u0439 \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u043e\u0439 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0435 \u043d\u0430\u043c \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u043b\u0438\u0448\u044c \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0434\u043b\u044f date \u0438 time_duration \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0439 \u043d\u0430\u0448\u0438\u0445 \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u044b\u0445 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440:  <\/p>\n<pre><code class=\"cpp\">template&lt;&gt; PyObject* type_into_python&lt;date&gt;::convert( date const& ); template&lt;&gt; void*     type_from_python&lt;date&gt;::convertible( PyObject* ); template&lt;&gt; void      type_from_python&lt;date&gt;::construct( PyObject*, converter::rvalue_from_python_stage1_data* );  template&lt;&gt; PyObject* type_into_python&lt;time_duration&gt;::convert( time_duration const& ); template&lt;&gt; void*     type_from_python&lt;time_duration&gt;::convertible( PyObject* ); template&lt;&gt; void      type_from_python&lt;time_duration&gt;::construct( PyObject*, converter::rvalue_from_python_stage1_data* ); <\/code><\/pre>\n<p>  \u0417\u0430\u0434\u0430\u0447\u0430 \u043d\u0435\u0441\u043b\u043e\u0436\u043d\u0430\u044f, \u0441\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u043a \u0440\u0430\u0437\u0431\u0438\u0435\u043d\u0438\u044e \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u043d\u0430 \u043f\u0430\u0440\u044b \u0434\u043b\u044f \u0434\u0430\u0442\u044b \u0438 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043f\u043e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438.<br \/>  \u0414\u043b\u044f <b>boost::gregorian::date<\/b> \u0438 <b>datetime.date<\/b>:  <\/p>\n<pre><code class=\"cpp\">PyObject* type_into_python&lt;date&gt;::convert( date const& d ) {     return PyDate_FromDate( d.year(), d.month(), d.day() ); }  void* type_from_python&lt;date&gt;::convertible( PyObject* obj ) {     return PyDate_Check( obj ) ? obj : nullptr; }  void type_from_python&lt;date&gt;::construct( PyObject* obj, converter::rvalue_from_python_stage1_data* data ) {     auto storage = reinterpret_cast&lt; converter::rvalue_from_python_storage&lt;date&gt;* &gt;( data )-&gt;storage.bytes;     new(storage) date( PyDateTime_GET_YEAR( obj ), PyDateTime_GET_MONTH( obj ), PyDateTime_GET_DAY( obj ) );     data-&gt;convertible = storage;  } <\/code><\/pre>\n<p>  \u0418 \u0434\u043b\u044f <b>boost::posix_time::time_duration<\/b> \u0438 <b>datetime.time<\/b>:  <\/p>\n<pre><code class=\"cpp\">PyObject* type_into_python&lt;time_duration&gt;::convert( time_duration const& t ) {     auto usec = t.total_microseconds() % 1000000;     return PyTime_FromTime( t.hours(), t.minutes(), t.seconds(), usec ); }  void* type_from_python&lt;time_duration&gt;::convertible( PyObject* obj ) {     return PyTime_Check( obj ) ? obj : nullptr; }  void type_from_python&lt;time_duration&gt;::construct( PyObject* obj, converter::rvalue_from_python_stage1_data* data ) {     auto storage = reinterpret_cast&lt; converter::rvalue_from_python_storage&lt;time_duration&gt;* &gt;( data )-&gt;storage.bytes;     time_duration* t = new(storage) time_duration( PyDateTime_TIME_GET_HOUR( obj ), PyDateTime_TIME_GET_MINUTE( obj ), PyDateTime_TIME_GET_SECOND( obj ) );     *t += microsec( PyDateTime_TIME_GET_MICROSECOND( obj ) );     data-&gt;convertible = storage;  } <\/code><\/pre>\n<p>  \u0420\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044f \u0432\u0441\u0435\u0433\u043e \u044d\u0442\u043e\u0433\u043e \u0434\u043e\u0431\u0440\u0430 \u0432 \u043d\u0430\u0448\u0435\u043c \u043c\u043e\u0434\u0443\u043b\u0435 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a:  <\/p>\n<pre><code class=\"cpp\">BOOST_PYTHON_MODULE( ... ) {     ...     PyDateTime_IMPORT;      to_python_converter&lt; ptime, type_into_python&lt;ptime&gt; &gt;();     type_from_python&lt; ptime &gt;();      to_python_converter&lt; date, type_into_python&lt;date&gt; &gt;();     type_from_python&lt; date &gt;();      to_python_converter&lt; time_duration, type_into_python&lt;time_duration&gt; &gt;();     type_from_python&lt; time_duration &gt;();     ... } <\/code><\/pre>\n<h4>\u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0440\u0430\u0431\u043e\u0442\u0443 \u0441 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u0435\u0439 \u0434\u0430\u0442\u044b \u0438 \u0432\u0440\u0435\u043c\u0435\u043d\u0438<\/h4>\n<p>  \u041f\u043e\u0440\u0430 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0432 \u0434\u0435\u043b\u0435 \u043d\u0430\u0448\u0443 \u043c\u0435\u0433\u0430\u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u044e, \u0437\u0430\u0432\u0435\u0434\u0451\u043c \u0432\u0441\u044f\u043a\u0438\u0435 \u043d\u0435\u043d\u0443\u0436\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0430 \u0432\u0445\u043e\u0434\u0435 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u044e\u0442 \u0434\u0430\u0442\u0443\/\u0432\u0440\u0435\u043c\u044f \u0438 \u043d\u0430 \u0432\u044b\u0445\u043e\u0434\u0435 \u0442\u043e\u0436\u0435 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0442 \u0434\u0430\u0442\u0443\/\u0432\u0440\u0435\u043c\u044f.  <\/p>\n<pre><code class=\"cpp\">ptime tomorrow(); ptime day_before( ptime const& the_moment );  date last_day_of_this_month(); date year_after( date const& the_day );  time_duration delta_between( ptime const& at, ptime const& to ); time_duration plus_midday( time_duration const& the_moment ); <\/code><\/pre>\n<p>  \u041e\u0431\u044a\u044f\u0432\u0438\u043c \u0438\u0445 \u0432 \u043d\u0430\u0448\u0435\u043c \u043c\u043e\u0434\u0443\u043b\u0435, \u0447\u0442\u043e\u0431\u044b \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u0438\u0437 Python:  <\/p>\n<pre><code class=\"cpp\">    def( &quot;tomorrow&quot;, tomorrow );     def( &quot;day_before&quot;, day_before, args( &quot;moment&quot; ) );     def( &quot;last_day_of_this_month&quot;, last_day_of_this_month );     def( &quot;year_after&quot;, year_after, args( &quot;day&quot; ) );     def( &quot;delta_between&quot;, delta_between, args( &quot;at&quot;, &quot;to&quot; ) );     def( &quot;plus_midday&quot;, plus_midday, args( &quot;moment&quot; ) ); <\/code><\/pre>\n<p>  \u041f\u0443\u0442\u044c \u044d\u0442\u0438 \u043d\u0430\u0448\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u0435\u043b\u0430\u044e\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435 (\u0445\u043e\u0442\u044f \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u044d\u0442\u043e \u0443\u0436\u0435 \u043d\u0435 \u0432\u0430\u0436\u043d\u043e, \u0432\u0430\u0436\u043d\u044b \u0442\u0438\u043f\u044b \u043d\u0430 \u0432\u0445\u043e\u0434\u0435\/\u0432\u044b\u0445\u043e\u0434\u0435):  <\/p>\n<pre><code class=\"cpp\">ptime tomorrow() {     return microsec_clock::local_time() + days( 1 ); }  ptime day_before( ptime const& that ) {     return that - days( 1 ); }  date last_day_of_this_month() {     date today = day_clock::local_day();     date next_first_day = (today.month() == Dec) ? date( today.year() + 1, 1, 1 ) : date( today.year(), today.month() + 1, 1 );     return next_first_day - days( 1 ); }  date year_after( date const& the_day ) {     return the_day + years( 1 ); }  time_duration delta_between( ptime const& at, ptime const& to ) {     return to - at; }  time_duration plus_midday( time_duration const& the_moment ) {     return time_duration( 12, 0, 0 ) + the_moment; } <\/code><\/pre>\n<p>  \u0412 \u0447\u0430\u0441\u0442\u043d\u043e\u0441\u0442\u0438 \u0432\u043e\u0442 \u0442\u0430\u043a\u043e\u0439 \u0432\u043e\u0442 \u043d\u0435\u0441\u043b\u043e\u0436\u043d\u044b\u0439 \u0441\u043a\u0440\u0438\u043f\u0442 (\u043d\u0430 Python 3.x):  <\/p>\n<pre><code class=\"python\">from someconv import * from datetime import * # test datetime.datetime &lt;=&gt; boost::posix_time::ptime t = tomorrow(); print( 'Tomorrow at same time:', t ) for _ in range(3): t = day_before(t); print( 'Day before that moment:', t ) # test datetime.date &lt;=&gt; boost::gregorian::date d = last_day_of_this_month(); print( 'Last day of this month:', d ) for _ in range(3): d = year_after(d); print( 'Day before that day:', d ) # test datetime.time &lt;=&gt; boost::posix_time::time_duration at = datetime.now() to = at + timedelta( seconds=12*60*60 ) dt = delta_between( at, to ) print( &quot;Delta between '{at}' and '{to}' is '{dt}'&quot;.format( at=at, to=to, dt=dt ) ) t0 = time( 6, 30, 0 ) t1 = plus_midday( t0 ) print( t0, &quot;plus midday is:&quot;, t1 ) <\/code><\/pre>\n<p>  \u0414\u043e\u043b\u0436\u0435\u043d \u043e\u0442\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e \u0438 \u0437\u0430\u0432\u0435\u0440\u0448\u0438\u0442\u044c\u0441\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0432\u043e\u0442 \u0441 \u0432\u044b\u0432\u043e\u0434\u043e\u043c \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u044b\u0445 \u0434\u0430\u0442 \u0438 \u0432\u0440\u0435\u043c\u0451\u043d. \u0422\u0435\u0441\u0442\u043e\u0432\u044b\u0439 \u0441\u043a\u0440\u0438\u043f\u0442 \u0440\u0430\u0437\u0443\u043c\u0435\u0435\u0442\u0441\u044f \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d. (\u0412\u044b\u0432\u043e\u0434 \u043d\u0435 \u043f\u0438\u0448\u0443, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u043f\u0430\u043b\u0438\u0442\u044c\u0441\u044f \u0432\u043e \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u044d\u0442\u043e \u0431\u044b\u043b\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043e!)<br \/>  \u041c\u043e\u0436\u0435\u0442\u0435 \u0432 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0435 \u043d\u0435 \u0441\u0442\u0435\u0441\u043d\u044f\u0442\u044c\u0441\u044f \u0438 \u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0432\u043e\u0438 \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043e\u043d\u0438 \u0432\u0441\u0435 \u043e\u0442\u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u043a\u0430\u043a \u043d\u0430\u0434\u043e, \u0435\u0441\u043b\u0438 \u0432\u044b \u0432\u0441\u0451 \u0441\u0434\u0435\u043b\u0430\u043b\u0438 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e.<br \/>  \u0412 \u043a\u0440\u0430\u0439\u043d\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0432 \u043a\u043e\u043d\u0446\u0435 \u0432\u044b\u043b\u043e\u0436\u0443 \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u043f\u0440\u043e\u0435\u043a\u0442 \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u043c \u0441\u043a\u0440\u0438\u043f\u0442\u043e\u043c.<\/p>\n<h4>\u0411\u0430\u0439\u0442\u043e\u0432\u044b\u0439 \u043c\u0430\u0441\u0441\u0438\u0432 \u0432 \u0432\u0438\u0434\u0435 \u0432\u0435\u043a\u0442\u043e\u0440\u0430 \u0431\u0430\u0439\u0442 \u0432 C++<\/h4>\n<p>  \u0412\u043e\u043e\u0431\u0449\u0435 \u0433\u043e\u0432\u043e\u0440\u044f \u043f\u0440\u0438\u0432\u0435\u0434\u0451\u043d\u043d\u044b\u0439 \u043d\u0438\u0436\u0435 \u043f\u0440\u0438\u043c\u0435\u0440 \u0432\u0440\u0435\u0434\u0435\u043d \u0447\u0440\u0435\u0437\u0432\u044b\u0447\u0430\u0439\u043d\u043e. \u0421\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u0448\u0430\u0431\u043b\u043e\u043d std::vector \u043f\u043e \u0442\u0438\u043f\u0443 \u0441 \u0440\u0430\u0437\u0440\u044f\u0434\u043d\u043e\u0441\u0442\u044c\u044e \u043d\u0438\u0436\u0435 int \u0431\u0443\u0434\u0435\u0442 \u043a\u0440\u0430\u0439\u043d\u0435 \u043d\u0435\u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u044b\u043c. \u041f\u0440\u043e\u0438\u0433\u0440\u044b\u0448 \u043f\u0440\u0438 \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u0438, \u043a\u0430\u043a \u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u0435, \u043f\u0440\u0438 vector::resize() \u0431\u0443\u0434\u0435\u0442 \u043a\u0430\u0442\u0430\u0441\u0442\u0440\u043e\u0444\u0438\u0447\u0435\u043d, \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u043e\u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u043f\u043e\u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043d\u043e. \u0421\u043e \u0432\u0441\u0435\u043c\u0438 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u043d\u044b\u043c\u0438 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044f\u043c\u0438 \u044d\u0442\u043e \u043f\u0440\u0438\u0432\u0435\u0434\u0451\u0442 \u043a \u043f\u043e\u0442\u0435\u0440\u044f\u043c \u0434\u043e 170% \u043f\u0440\u0438 \u043f\u0440\u043e\u0441\u0442\u043e\u043c \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u0432 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0438 \u0441 memcpy() (\u0437\u0430\u043c\u0435\u0440\u044f\u043b\u043e\u0441\u044c \u0432 Release-\u0441\u0431\u043e\u0440\u043a\u0435 MSVS v10). \u0427\u0442\u043e \u043d\u0435 \u043e\u0441\u043e\u0431\u043e \u043f\u0440\u0438\u044f\u0442\u043d\u043e \u0434\u043b\u044f \u0447\u0430\u0441\u0442\u043e\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u043e\u0433\u043e \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u0430 \u043a\u043e\u0434\u0430. \u041e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u043a\u043e\u0433\u0434\u0430 \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043d\u0435 \u0432\u0438\u0434\u043d\u043e, \u0430 \u0438\u043d\u043e\u0433\u0434\u0430 \u043d\u0435\u044f\u0432\u043d\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 resize(). \u0412\u043e\u0437\u043d\u0438\u043a\u0430\u044e\u0442 \u00ab\u0437\u0430\u043d\u044f\u0442\u043d\u044b\u0435\u00bb \u043f\u0440\u043e\u0441\u0435\u0434\u0430\u043d\u0438\u044f \u043f\u043e \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438, \u0432 \u0442\u043e\u043c \u0441\u043c\u044b\u0441\u043b\u0435 \u0447\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0447\u0435\u043c \u0437\u0430\u043d\u044f\u0442\u044c\u0441\u044f, \u043e\u0442\u043b\u0430\u0432\u043b\u0438\u0432\u0430\u044f \u0442\u043e\u0440\u043c\u043e\u0437\u0430 \u0432 \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u0435.<\/p>\n<p>  \u041f\u0440\u0438\u043c\u0435\u0440 \u043d\u0438\u0436\u0435 \u0447\u0438\u0441\u0442\u043e \u0430\u043a\u0430\u0434\u0435\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u0439, \u0435\u0441\u043b\u0438 \u0432\u0430\u043c \u0433\u0434\u0435-\u043b\u0438\u0431\u043e \u043d\u0443\u0436\u043d\u0430 \u043c\u0430\u043d\u0438\u0430\u043a\u0430\u043b\u044c\u043d\u0430\u044f \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044f \u043a\u043e\u0434\u0430 \u0438 \u0432\u044b \u0438\u043c\u0435\u043d\u043d\u043e \u0437\u0430 \u044d\u0442\u0438\u043c \u043f\u0438\u0448\u0435\u0442\u0435 \u0447\u0430\u0441\u0442\u044c \u043a\u043e\u0434\u0430 \u043c\u043e\u0434\u0443\u043b\u044f \u043d\u0430 \u0421++. \u0415\u0441\u043b\u0438 \u0436\u0435 \u0432\u0430\u043c \u043f\u043e\u0431\u043e\u043a\u0443 \u043d\u0430 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c, \u0441\u043c\u0435\u043b\u043e \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u043e\u0435 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435.<br \/>  \u0414\u043b\u044f Python 2.x \u0434\u0430\u043d\u043d\u044b\u0439 \u0440\u0430\u0437\u0434\u0435\u043b \u043d\u0435\u0430\u043a\u0442\u0443\u0430\u043b\u0435\u043d \u0432 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0435. \u0422\u043e\u0433\u0434\u0430 \u0431\u0430\u0439\u0442\u043e\u0432\u044b\u0435 \u043c\u0430\u0441\u0441\u0438\u0432\u044b \u043d\u0430\u0437\u044b\u0432\u0430\u043b\u0438\u0441\u044c \u0441\u0442\u0440\u043e\u043a\u0430\u043c\u0438. \u041a\u0443\u0434\u0430 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0435\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u043f\u0440\u043e \u0440\u0430\u0431\u043e\u0442\u0443 \u0441 unicode \u0438 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0435\u0433\u043e \u0432 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443 C++ <a href=\"http:\/\/wiki.python.org\/moin\/boost.python\/EmbeddingPython#Working_with_Unicode\">\u0437\u0434\u0435\u0441\u044c \u0432 PyWiki<\/a>.<br \/>  \u0417\u0430\u0442\u043e \u0434\u043b\u044f Python 3.x \u0434\u0430\u043d\u043d\u043e\u0435 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u0441\u043e\u043a\u0440\u0430\u0442\u0438\u0442\u044c \u0433\u0440\u043e\u043c\u0430\u0434\u043d\u044b\u0439 \u043a\u0443\u0441\u043e\u043a \u043a\u043e\u0434\u0430 c \u043a\u0443\u0447\u0435\u0439 C-API \u0434\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043e\u0431\u044b\u0447\u043d\u043e\u0433\u043e vector (<b>byte<\/b> \u2014 \u0431\u0435\u0437\u0437\u043d\u0430\u043a\u043e\u0432\u043e\u0435 8-\u0431\u0438\u0442\u043d\u043e\u0435 \u0446\u0435\u043b\u043e\u0435 \u2014 <b>uint8_t<\/b>).<\/p>\n<p>  \u0418\u0442\u0430\u043a, \u0441\u043d\u043e\u0432\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043d\u0430\u0448\u0438 \u0437\u0430\u043c\u0435\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u044b\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0438 \u0440\u0430\u0434\u0443\u0435\u043c\u0441\u044f:  <\/p>\n<pre><code class=\"cpp\">typedef uint8_t byte; typedef vector&lt;byte&gt; byte_array; ... template&lt;&gt; PyObject* type_into_python&lt;byte_array&gt;::convert( byte_array const& ); template&lt;&gt; void*     type_from_python&lt;byte_array&gt;::convertible( PyObject* ); template&lt;&gt; void      type_from_python&lt;byte_array&gt;::construct( PyObject*, converter::rvalue_from_python_stage1_data* ); <\/code><\/pre>\n<p>  \u0412\u0441\u0451 \u0442\u0430\u043a \u0436\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0432 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435 \u043d\u0430\u0448\u0435\u0433\u043e \u043c\u043e\u0434\u0443\u043b\u044f \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044e \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0435\u0440\u043e\u0432:  <\/p>\n<pre><code class=\"cpp\">BOOST_PYTHON_MODULE( ... ) {     ...     to_python_converter&lt; byte_array, type_into_python&lt;byte_array&gt; &gt;();     type_from_python&lt; byte_array &gt;(); } <\/code><\/pre>\n<p>  \u0418 \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u043e \u0437\u043d\u0430\u043d\u0438\u0435 C-API \u043e\u0431\u044a\u0435\u043a\u0442\u0430 PyBytes \u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u043c \u0441 \u043c\u0435\u0442\u043e\u0434\u0430\u043c\u0438 std::vector:  <\/p>\n<pre><code class=\"cpp\">PyObject* type_into_python&lt;byte_array&gt;::convert( byte_array const& ba ) {     const char* src = ba.empty() ? &quot;&quot; : reinterpret_cast&lt;const char*&gt;( &ba.front() );     return PyBytes_FromStringAndSize( src, ba.size() ); }  void* type_from_python&lt;byte_array&gt;::convertible( PyObject* obj ) {     return PyBytes_Check( obj ) ? obj : nullptr; }  void type_from_python&lt;byte_array&gt;::construct( PyObject* obj, converter::rvalue_from_python_stage1_data* data ) {     auto storage = reinterpret_cast&lt; converter::rvalue_from_python_storage&lt;byte_array&gt;* &gt;( data )-&gt;storage.bytes;     byte* dest; Py_ssize_t len;     PyBytes_AsStringAndSize( obj, reinterpret_cast&lt;char**&gt;( &dest ), &len );     new(storage) byte_array( dest, dest + len );     data-&gt;convertible = storage;  } <\/code><\/pre>\n<p>  \u0412\u0440\u044f\u0434 \u043b\u0438 \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u044e\u0442\u0441\u044f \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0438, \u0437\u0430 \u0437\u043d\u0430\u043d\u0438\u044f\u043c\u0438 C-API \u043e\u0431\u044a\u0435\u043a\u0442\u0430 PyBytes \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044e <a href=\"http:\/\/docs.python.org\/3\/c-api\/bytes.html?highlight=pybytes#bytes-objects\">\u0432\u043e\u0442 \u0441\u044e\u0434\u0430<\/a>.<\/p>\n<h4>\u041f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u043c uuid.UUID \u0432 boost::uuids::uuid \u0438 \u043e\u0431\u0440\u0430\u0442\u043d\u043e<\/h4>\n<p>  \u0412\u044b \u0431\u0443\u0434\u0435\u0442\u0435 \u0441\u043c\u0435\u044f\u0442\u0441\u044f, \u043d\u043e \u043c\u044b \u0434\u043e \u0442\u043e\u0433\u043e \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u043b\u0438 \u0441\u0435\u0431\u0435 \u0440\u0430\u0431\u043e\u0442\u0443, \u0441\u043e\u0437\u0434\u0430\u0432 \u0442\u0435 \u0434\u0432\u0430 \u0448\u0430\u0431\u043b\u043e\u043d\u0430 \u0432 \u0441\u0430\u043c\u043e\u043c \u043d\u0430\u0447\u0430\u043b\u0435, \u0447\u0442\u043e \u043e\u043f\u044f\u0442\u044c \u0436\u0435 \u0432\u0441\u0451 \u0441\u0432\u0435\u0434\u0451\u0442\u0441\u044f \u043a \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0442\u0440\u043e\u0439\u043a\u0438 \u043c\u0435\u0442\u043e\u0434\u043e\u0432:  <\/p>\n<pre><code class=\"cpp\">using namespace boost::uuids; ... template&lt;&gt; PyObject* type_into_python&lt;uuid&gt;::convert( uuid const& ); template&lt;&gt; void*     type_from_python&lt;uuid&gt;::convertible( PyObject* ); template&lt;&gt; void      type_from_python&lt;uuid&gt;::construct( PyObject*, converter::rvalue_from_python_stage1_data* ); <\/code><\/pre>\n<p>  \u041f\u0440\u0438\u0432\u044b\u0447\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0432 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435 \u043c\u043e\u0434\u0443\u043b\u044f \u0434\u0432\u0435 \u043d\u043e\u0432\u044b\u0445 \u0441\u0442\u0440\u043e\u0447\u043a\u0438 \u2014 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044e \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u0438 \u0442\u0443\u0434\u0430 \u0438 \u043e\u0431\u0440\u0430\u0442\u043d\u043e:  <\/p>\n<pre><code class=\"cpp\">    to_python_converter&lt; uuid, type_into_python&lt;uuid&gt; &gt;();     type_from_python&lt; uuid &gt;(); <\/code><\/pre>\n<p>  \u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u0441\u0430\u043c\u043e\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0435, C-API \u0442\u0443\u0442 \u043d\u0430\u043c \u043d\u0435 \u043f\u043e\u043c\u043e\u0436\u0435\u0442, \u0441\u043a\u043e\u0440\u0435\u0435 \u043f\u043e\u043c\u0435\u0448\u0430\u0435\u0442, \u043f\u0440\u043e\u0449\u0435 \u0432\u0441\u0435\u0433\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0447\u0435\u0440\u0435\u0437 boost::python::import \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043c\u043e\u0434\u0443\u043b\u044f Python \u00abuuid\u00bb \u0438 \u043a\u043b\u0430\u0441\u0441\u0430 \u00abUUID\u00bb \u044d\u0442\u043e\u0433\u043e \u0436\u0435 \u043c\u043e\u0434\u0443\u043b\u044f.  <\/p>\n<pre><code class=\"cpp\">static object py_uuid = import( &quot;uuid&quot; ); static object py_uuid_UUID = py_uuid.attr( &quot;UUID&quot; );  PyObject* type_into_python&lt;uuid&gt;::convert( uuid const& u ) {     return incref( py_uuid_UUID( object(), byte_array( u.data, u.data + sizeof(u.data) ) ).ptr() ); }  void* type_from_python&lt;uuid&gt;::convertible( PyObject* obj ) {     return PyObject_IsInstance( obj, py_uuid_UUID.ptr() ) ? obj : nullptr; }  void type_from_python&lt;uuid&gt;::construct( PyObject* obj, converter::rvalue_from_python_stage1_data* data ) {     auto storage = reinterpret_cast&lt; converter::rvalue_from_python_storage&lt;uuid&gt;* &gt;( data )-&gt;storage.bytes;     byte_array ba = extract&lt;byte_array&gt;( object( handle&lt;&gt;( borrowed( obj ) ) ).attr( &quot;bytes&quot; ) );     uuid* res = new(storage) uuid;     memcpy( res-&gt;data, &ba.front(), ba.size() );     data-&gt;convertible = storage; } <\/code><\/pre>\n<p>  \u0423\u0436 \u0438\u0437\u0432\u0438\u043d\u0438\u0442\u0435, \u0447\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435, \u043e\u0431\u044b\u0447\u043d\u043e \u044d\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u0432 \u0441\u0438\u043d\u0433\u043b\u0442\u043e\u043d\u0435 \u0441 Py_Initialize() \u0438 Py_Finalize() \u0432 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0435 \u0438 \u0434\u0435\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0435 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e. \u041d\u043e \u0440\u0430\u0437 \u0443\u0436 \u0442\u0443\u0442 \u0443 \u043d\u0430\u0441 \u043f\u0440\u0438\u043c\u0435\u0440 \u0447\u0438\u0441\u0442\u043e \u0443\u0447\u0435\u0431\u043d\u044b\u0439 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043f\u043e\u043a\u0430 \u0442\u043e\u043b\u044c\u043a\u043e \u0438\u0437 Python, \u0442\u043e \u043c\u043e\u0436\u043d\u043e \u043e\u0431\u043e\u0439\u0442\u0438\u0441\u044c \u0442\u0430\u043a\u0438\u043c \u0431\u044b\u0434\u043b\u043e\u043f\u043e\u0434\u0445\u043e\u0434\u043e\u043c, \u0435\u0449\u0451 \u0440\u0430\u0437 \u043f\u0440\u043e\u0441\u0442\u0438\u0442\u0435, \u043d\u043e \u0442\u0430\u043a \u043a\u043e\u0434 \u043f\u043e\u043d\u044f\u0442\u043d\u0435\u0435.<\/p>\n<p>  \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0432 \u044d\u0442\u0438\u0445 \u043c\u0435\u0442\u043e\u0434\u0430\u0445 \u0441\u0438\u043b\u044c\u043d\u043e \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f \u043e\u0442 \u0432\u0441\u0435\u0433\u043e \u0432\u044b\u0448\u0435\u043e\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0433\u043e, \u043d\u0430\u0434\u043e \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043e\u043f\u0438\u0441\u0430\u0442\u044c, \u0447\u0442\u043e \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442.<br \/>  \u0412 py_uuid \u043c\u044b \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u043b\u0438 \u043e\u0431\u044a\u0435\u043a\u0442 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u043d\u043e\u0433\u043e \u043c\u043e\u0434\u0443\u043b\u044f uuid \u0438\u0437 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 Python.<br \/>  \u0412 py_uuid_UUID \u043c\u044b \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u043b\u0438 \u043e\u0431\u044a\u0435\u043a\u0442 \u043a\u043b\u0430\u0441\u0441\u0430 uuid.UUID. \u0418\u043c\u0435\u043d\u043d\u043e \u0441\u0430\u043c \u043a\u043b\u0430\u0441\u0441 \u043a\u0430\u043a \u0442\u0430\u043a\u043e\u0432\u043e\u0439. \u041f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0441\u043a\u043e\u0431\u043e\u043a \u043a \u0434\u0430\u043d\u043d\u043e\u043c\u0443 \u043e\u0431\u044a\u0435\u043a\u0442\u0443 \u043f\u0440\u0438\u0432\u0435\u0434\u0451\u0442 \u043a \u0432\u044b\u0437\u043e\u0432\u0443 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430 \u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044e \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0430. \u0427\u0442\u043e \u043c\u044b \u0432\u043f\u043e\u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u0438 \u0438 \u0441\u0434\u0435\u043b\u0430\u0435\u043c. \u041e\u0434\u043d\u0430\u043a\u043e \u0441\u0430\u043c \u044d\u0442\u043e\u0442 \u043a\u043b\u0430\u0441\u0441 \u043a\u0430\u043a \u0442\u0430\u043a\u043e\u0432\u043e\u0439 \u043d\u0430\u043c \u0435\u0449\u0451 \u043f\u0440\u0438\u0433\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u0434\u043b\u044f \u043c\u0435\u0442\u043e\u0434\u0430 convertible \u2014 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0442\u0438\u043f\u0430 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u0438 \u043e\u0431\u044a\u0435\u043a\u0442 UUID&#8217;\u043e\u043c.<\/p>\n<p>  \u0412 \u0441\u0442\u043e\u0440\u043e\u043d\u0443 Python \u0438\u0437 C++ \u0432\u0441\u0451 \u043f\u043e\u043d\u044f\u0442\u043d\u043e \u2014 \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440, \u0432 \u043f\u0435\u0440\u0432\u044b\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u043f\u0435\u0440\u0435\u0434\u0430\u0451\u043c <b>None<\/b> (<i>\u0434\u0435\u0444\u043e\u043b\u0442\u043d\u044b\u0439 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 boost::python::object \u0441\u043e\u0437\u0434\u0430\u0441\u0442 \u043a\u0430\u043a \u0440\u0430\u0437 <b>None<\/b><\/i>), \u0432\u043e \u0432\u0442\u043e\u0440\u043e\u0439 \u0443\u0445\u043e\u0434\u0438\u0442 \u043d\u0430\u0448 \u0431\u0430\u0439\u0442\u043e\u0432\u044b\u0439 \u043c\u0430\u0441\u0441\u0438\u0432 \u0438\u0437 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0433\u043e \u0440\u0430\u0437\u0434\u0435\u043b\u0430. \u0415\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 Python 2.x \u043a\u043e\u0434 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u043e\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u0438 \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u0442\u044c\u0441\u044f, \u0442\u0430\u043c \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0441\u0442\u0440\u043e\u043a\u0443 \u0438 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0432\u0438\u0434, \u0447\u0442\u043e \u044d\u0442\u043e \u0431\u0430\u0439\u0442\u043e\u0432\u044b\u0439 \u043c\u0430\u0441\u0441\u0438\u0432.<\/p>\n<p>  \u041f\u0440\u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0435 Python-\u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u043d\u0430 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0431\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043d\u0430\u043c \u0437\u0434\u043e\u0440\u043e\u0432\u043e \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u044f PyObject_IsInstance().<br \/>  \u0423\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c PyObject* \u0442\u0438\u043f\u0430 uuid.UUID \u0431\u0435\u0440\u0451\u043c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u0435\u0442\u043e\u0434\u0430 ptr() \u043a\u043b\u0430\u0441\u0441\u0430 boost::python::object. \u0412\u043e\u0442 \u0442\u0443\u0442 \u043d\u0430\u043c \u0438 \u043f\u0440\u0438\u0433\u043e\u0434\u0438\u043b\u0441\u044f \u043e\u0431\u044a\u0435\u043a\u0442 \u043a\u043b\u0430\u0441\u0441\u0430 \u043a\u0430\u043a \u0442\u0430\u043a\u043e\u0432\u043e\u0439. \u041f\u043e \u0444\u0430\u043a\u0442\u0443 \u043a\u043b\u0430\u0441\u0441\u044b \u0432 Python \u0442\u0430\u043a\u0438\u0435 \u0436\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b. \u0418 \u044d\u0442\u043e \u0437\u0434\u043e\u0440\u043e\u0432\u043e. \u0421\u043f\u0430\u0441\u0438\u0431\u043e \u0437\u0430 \u0441\u0442\u043e\u043b\u044c \u043b\u043e\u0433\u0438\u0447\u043d\u044b\u0439 \u0438 \u043f\u043e\u043d\u044f\u0442\u043d\u044b\u0439 \u044f\u0437\u044b\u043a.<\/p>\n<p>  \u0412\u043e\u0442 \u043a\u043e\u0434 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0438\u0437 Python \u0432 C++ \u0443\u0436\u0435 \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u043f\u043e\u043d\u044f\u0442\u043d\u043e, \u0447\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043d\u0430 \u044d\u0442\u043e\u0439 \u0441\u0442\u0440\u043e\u0447\u043a\u0435:  <\/p>\n<pre><code class=\"cpp\">    byte_array ba = extract&lt;byte_array&gt;( object( handle&lt;&gt;( borrowed( obj ) ) ).attr( &quot;bytes&quot; ) ); <\/code><\/pre>\n<p>  \u0417\u0434\u0435\u0441\u044c \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u0432\u0441\u0451 \u043f\u0440\u0435\u0434\u0435\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e. \u0418\u0437 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 uuid.UUID \u043f\u0440\u0438\u0448\u0435\u0434\u0448\u0435\u0433\u043e \u043a\u0430\u043a PyObject* \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0451\u043c \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u044b\u0439 boost::python::object. \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044e handle&lt;&gt;( <b>borrowed<\/b>( obj ) ) \u2014 \u0437\u0434\u0435\u0441\u044c \u043e\u0447\u0435\u043d\u044c \u0432\u0430\u0436\u043d\u043e \u043d\u0435 \u043f\u043e\u0442\u0435\u0440\u044f\u0442\u044c \u0432\u044b\u0437\u043e\u0432 borrowed, \u0438\u043d\u0430\u0447\u0435 \u043d\u0430\u0448 \u0441\u0432\u0435\u0436\u0438\u0439 object \u0433\u0440\u043e\u0445\u043d\u0435\u0442 \u0432 \u0434\u0435\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442.<br \/>  \u0418\u0442\u0430\u043a, \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0438\u0437 PyObject* \u043e\u0431\u044a\u0435\u043a\u0442 boost::python::object \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435 \u043d\u0430 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 \u0442\u0438\u043f\u0430 uuid.UUID. \u0411\u0435\u0440\u0451\u043c \u0443 \u043d\u0430\u0448\u0435\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0430\u0442\u0440\u0438\u0431\u0443\u0442 <b>bytes<\/b>, \u0432\u044b\u0442\u0430\u0441\u043a\u0438\u0432\u0430\u0435\u043c \u0438\u0437 \u043d\u0435\u0433\u043e byte_array \u0447\u0435\u0440\u0435\u0437 extract. \u0412\u0441\u0451, \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435.<br \/>  \u041b\u044e\u0431\u0438\u0442\u0435\u043b\u0438 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0432\u0441\u0451 \u0447\u0435\u0440\u0435\u0437 \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e-\u0434\u0435\u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u043c\u043e\u0433\u0443\u0442 \u043f\u043e\u0438\u0441\u043f\u0440\u0430\u0436\u043d\u044f\u0442\u044c\u0441\u044f \u0447\u0435\u0440\u0435\u0437 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0432 \u0441\u0442\u0440\u043e\u043a\u0443 \u0438 \u043e\u0431\u0440\u0430\u0442\u043d\u043e. \u0412\u0441\u044f\u043a\u0438\u0439 lexical_cast() \u0438\u043c \u0432 \u043f\u043e\u043c\u043e\u0449\u044c \u0438 \u043a\u0430\u043c\u0435\u043d\u044c \u043d\u0430 \u0448\u0435\u044e. \u041f\u043e\u043c\u043d\u0438\u0442\u0435, \u0447\u0442\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0441\u0442\u0440\u043e\u043a \u0438 \u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0432 C++ \u043f\u043e \u0441\u0443\u0442\u0438 \u043e\u0447\u0435\u043d\u044c \u0434\u043e\u0440\u043e\u0433\u0430\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f.<br \/>  \u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438 Python 2.x \u0441\u0440\u0430\u0437\u0443 \u0436\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0442 \u0431\u0430\u0439\u0442\u044b \u0432 \u0432\u0438\u0434\u0435 \u0441\u0442\u0440\u043e\u043a\u0438. \u0422\u0430\u043a\u0438\u0435 \u0443\u0436 \u0440\u0430\u043d\u044c\u0448\u0435 \u0431\u044b\u043b\u0438 \u0441\u0442\u0440\u043e\u043a\u0438, \u043a\u0430\u043a \u0438 \u0432 C\/C++, \u043f\u043e \u0441\u0443\u0442\u0438 \u0447\u0435\u0440\u0435\u0437 char*.<br \/>  \u0412 \u043e\u0431\u0449\u0435\u043c \u0434\u0430\u043b\u044c\u0448\u0435 \u0432\u0441\u0451 \u043f\u0440\u043e\u0441\u0442\u043e, \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u043c\u0430\u0441\u0441\u0438\u0432, \u0443\u0436 \u0438\u0437\u0432\u0438\u043d\u0438\u0442\u0435 \u0437\u0430 \u043d\u0435\u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0435 \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435, \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0451\u043c \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u043d\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 \u043e\u0431\u0440\u0430\u0442\u043d\u043e \u0432 C++.<\/p>\n<h4>\u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0440\u0430\u0431\u043e\u0442\u0443 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0439 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u0431\u0430\u0439\u0442 \u0438 UUID<\/h4>\n<p>  \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0437\u0430\u0432\u0435\u0434\u0451\u043c \u0435\u0449\u0451 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0433\u043e\u043d\u044f\u044e\u0449\u0438\u0445 \u0442\u0443\u0434\u0430-\u0441\u044e\u0434\u0430 \u043d\u0430\u0448\u0438 \u0442\u0438\u043f\u044b \u043c\u0435\u0436\u0434\u0443 C++ \u0438 Python:  <\/p>\n<pre><code class=\"cpp\">byte_array string_to_bytes( string const& src ); string bytes_to_string( byte_array const& src );  uuid random_uuid(); byte_array uuid_bytes( uuid const& src ); <\/code><\/pre>\n<p>  \u041e\u043f\u0438\u0448\u0435\u043c \u0438\u0445 \u0432 \u043d\u0430\u0448\u0435\u043c \u043c\u043e\u0434\u0443\u043b\u0435 \u0434\u043b\u044f \u0432\u044b\u0437\u043e\u0432\u0430 \u0438\u0437 Python:  <\/p>\n<pre><code class=\"cpp\">BOOST_PYTHON_MODULE( someconv ) {     ...     def( &quot;string_to_bytes&quot;, string_to_bytes, args( &quot;src&quot; ) );     def( &quot;bytes_to_string&quot;, bytes_to_string, args( &quot;src&quot; ) );     def( &quot;random_uuid&quot;, random_uuid );     def( &quot;uuid_bytes&quot;, uuid_bytes, args( &quot;src&quot; ) );     ... } <\/code><\/pre>\n<p>  \u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0438\u0445 \u043d\u0435 \u0441\u0442\u043e\u043b\u044c \u0432\u0430\u0436\u043d\u043e, \u043e\u0434\u043d\u0430\u043a\u043e \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0447\u0435\u0441\u0442\u043d\u043e \u043e\u043f\u0438\u0448\u0435\u043c \u0438\u0445 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0434\u043b\u044f \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u043e\u0441\u0442\u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430:  <\/p>\n<pre><code class=\"cpp\">byte_array string_to_bytes( std::string const& src ) {     return byte_array( src.begin(), src.end() ); }  string bytes_to_string( byte_array const& src ) {     return string( src.begin(), src.end() ); }  uuid random_uuid() {     static random_generator gen_uuid;     return gen_uuid(); }  byte_array uuid_bytes( uuid const& src ) {     return byte_array( src.data, src.data + sizeof(src.data) ); } <\/code><\/pre>\n<p>  \u0412 \u043e\u0431\u0449\u0435\u043c \u0438 \u0446\u0435\u043b\u043e\u043c \u0442\u0430\u043a\u043e\u0439 \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0439 \u0441\u043a\u0440\u0438\u043f\u0442 (\u043d\u0430 Python 3.x):  <\/p>\n<pre><code class=\"python\">from someconv import * from uuid import * ... # test bytes &lt;=&gt; std::vector&lt;uint8_t&gt; print( bytes_to_string( b&quot;I_must_be_string&quot; ) ) print( string_to_bytes( &quot;I_must_be_byte_array&quot; ) ) print( bytes_to_string( &quot; - \u041f\u0440\u0438\u0432\u0435\u0442!&quot;.encode() ) ) print( string_to_bytes( &quot; - \u041f\u043e\u043a\u0430!&quot; ).decode() ) print( bytes_to_string( string_to_bytes( &quot; - \u041d\u0443 \u043f\u043e\u043a\u0430!&quot; ) ) ) # test uuid.UUID &lt;=&gt; boost::uuids::uuid u = random_uuid() print( 'Generated UUID (C++ module):', uuid_bytes(u) ) print( 'Generated UUID (in Python): ', u.bytes) <\/code><\/pre>\n<p>  \u0414\u043e\u043b\u0436\u0435\u043d \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e \u043e\u0442\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0438 \u0432\u044b\u0434\u0430\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0447\u0442\u043e-\u0442\u043e \u0432\u0440\u043e\u0434\u0435:  <\/p>\n<pre><code class=\"python\">I_must_be_string b'I_must_be_byte_array'  - \u041f\u0440\u0438\u0432\u0435\u0442!  - \u041f\u043e\u043a\u0430!  - \u041d\u0443 \u043f\u043e\u043a\u0430! Generated UUID (C++ module): b'\\xf1B\\xdb\\xa9&lt;lL\\x9d\\x9a\\xfd\\xf3\\xe9\\x9f\\xa6\\x9aT' Generated UUID (in Python):  b'\\xf1B\\xdb\\xa9&lt;lL\\x9d\\x9a\\xfd\\xf3\\xe9\\x9f\\xa6\\x9aT' <\/code><\/pre>\n<p>  \u041a\u0441\u0442\u0430\u0442\u0438, \u0435\u0441\u043b\u0438 \u0432\u044b \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0432\u043e\u0437\u044c\u043c\u0451\u0442\u0435 \u0438 \u0443\u0434\u0430\u043b\u0438\u0442\u0435 borrowed \u0438\u0437 \u043a\u043e\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u0438 UUID \u0438\u0437 Python \u0432 C++, \u0442\u043e \u0441\u0432\u0430\u043b\u0438\u0442\u0435\u0441\u044c \u0440\u043e\u0432\u043d\u043e \u043d\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0439 \u0441\u0442\u0440\u043e\u0447\u043a\u0435, \u0442\u0430\u043a \u043a\u0430\u043a \u043e\u0431\u044a\u0435\u043a\u0442 \u0431\u0443\u0434\u0435\u0442 \u0443\u0436\u0435 \u0443\u043d\u0438\u0447\u0442\u043e\u0436\u0435\u043d \u0438 \u043d\u0435 \u0443 \u0447\u0435\u0433\u043e \u0431\u0443\u0434\u0435\u0442 \u0431\u0440\u0430\u0442\u044c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e bytes.<\/p>\n<h4>\u0418\u0442\u043e\u0433\u043e<\/h4>\n<p>  \u041c\u044b \u043d\u0430\u0443\u0447\u0438\u043b\u0438\u0441\u044c \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0438\u0441\u0430\u0442\u044c \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0435\u0440\u044b, \u043d\u043e \u0438 \u043e\u0431\u043e\u0431\u0449\u0430\u0442\u044c \u0438\u0445, \u0441\u0432\u043e\u0434\u0438\u0442\u044c \u0442\u0440\u0443\u0434\u043e\u0432\u044b\u0435 \u0437\u0430\u0442\u0440\u0430\u0442\u044b \u043f\u0440\u0438 \u0438\u0445 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0438 \u043a \u043c\u0438\u043d\u0438\u043c\u0443\u043c\u0443 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u0434\u0438\u043d \u0438\u0437 \u0434\u0440\u0443\u0433\u043e\u0433\u043e. \u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043c\u044b \u0443\u0436\u0435 \u0437\u043d\u0430\u0435\u043c \u0447\u0442\u043e \u044d\u0442\u043e, \u043a\u0430\u043a \u044d\u0442\u0438\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0438 \u0433\u0434\u0435 \u043e\u043d\u043e \u0436\u0438\u0437\u043d\u0435\u043d\u043d\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e.<br \/>  \u0421\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043f\u0440\u043e\u0435\u043a\u0442 \u043b\u0435\u0436\u0438\u0442 <a href=\"http:\/\/www.2shared.com\/file\/lULxBoyM\/someconv.html\">\u0437\u0434\u0435\u0441\u044c (~207 KB)<\/a>. \u041f\u0440\u043e\u0435\u043a\u0442 MSVS v11, \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043d \u043d\u0430 \u0441\u0431\u043e\u0440\u043a\u0443 \u0441 Python 3.3 x64.<\/p>\n<h4>\u041f\u043e\u043b\u0435\u0437\u043d\u044b\u0435 \u0441\u0441\u044b\u043b\u043a\u0438<\/h4>\n<p>  <a href=\"http:\/\/www.boost.org\/doc\/libs\/1_52_0\/libs\/python\/doc\/\">\u0414\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f Boost.Python<\/a><br \/>  <a href=\"http:\/\/misspent.wordpress.com\/2009\/09\/27\/how-to-write-boost-python-converters\/\">\u041a\u0430\u043a \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0435\u0440 \u0441\u0442\u0440\u043e\u043a\u0438<\/a><br \/>  <a href=\"http:\/\/wiki.python.org\/moin\/boost.python\/EmbeddingPython#Working_with_Unicode\">\u0420\u0430\u0431\u043e\u0442\u0430 \u0441 Unicode \u0432 Python 2.x<\/a><br \/>  <a href=\"http:\/\/code.activestate.com\/lists\/python-cplusplus-sig\/16463\/\">\u041f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u0432 \u043c\u0435\u0436\u0434\u0443 C++ \u0438 Python<\/a><br \/>  <a href=\"http:\/\/code.activestate.com\/recipes\/576395-convert-datetimedatetime-objects-tofrom-boostpytho\/\">\u0415\u0449\u0451 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u0438 \u0434\u0430\u0442\u044b\/\u0432\u0440\u0435\u043c\u0435\u043d\u0438<\/a>    \t \t\t   \t<\/p>\n<div class=\"clear\"><\/div>\n<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/168827\/\"> http:\/\/habrahabr.ru\/post\/168827\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\">   \t\u0414\u0430\u043d\u043d\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0435\u043d\u0438\u0435\u043c \u043f\u043e\u0432\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u0438\u044f \u043e\u0431 \u043e\u0431\u0451\u0440\u0442\u043a\u0430\u0445 C++ API. \u041d\u0438\u043a\u0430\u043a\u0438\u0445 \u043e\u0431\u0451\u0440\u0442\u043e\u043a \u0441\u0435\u0433\u043e\u0434\u043d\u044f \u043d\u0435 \u0431\u0443\u0434\u0435\u0442. \u0425\u043e\u0442\u044f \u043f\u043e \u043b\u043e\u0433\u0438\u043a\u0435 \u044d\u0442\u043e \u0442\u0440\u0435\u0442\u044c\u044f \u0447\u0430\u0441\u0442\u044c <a href=\"http:\/\/habrahabr.ru\/post\/168083\/\">\u0434\u0430\u043d\u043d\u043e\u0433\u043e<\/a> <a href=\"http:\/\/habrahabr.ru\/post\/168233\/\">\u043f\u043e\u0432\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u0438\u044f<\/a>.<br \/>  \u0421\u0435\u0433\u043e\u0434\u043d\u044f \u0431\u0443\u0434\u0435\u0442 \u043c\u043e\u0440\u0435 \u043a\u0440\u043e\u0432\u0438, \u0440\u0430\u0441\u0447\u043b\u0435\u043d\u0435\u043d\u0438\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u0442\u0438\u043f\u043e\u0432 \u0438 \u043c\u0430\u0433\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0435\u043d\u0438\u0435 \u0438\u0445 \u0432 \u043f\u0440\u0438\u0432\u044b\u0447\u043d\u044b\u0435 \u0430\u043d\u0430\u043b\u043e\u0433\u0438 \u0432 \u0434\u0440\u0443\u0433\u043e\u043c \u044f\u0437\u044b\u043a\u0435.<br \/>  \u0420\u0435\u0447\u044c \u043d\u0435 \u043f\u043e\u0439\u0434\u0451\u0442 \u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0439 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u0438 \u043c\u0435\u0436\u0434\u0443 \u0441\u0442\u0440\u043e\u043a\u0430\u043c\u0438, \u043d\u0435\u0442, \u043c\u044b \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u0441\u0432\u043e\u0438 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0435\u0440\u044b.<br \/>  \u041c\u044b \u043f\u0440\u0435\u0432\u0440\u0430\u0442\u0438\u043c \u043f\u0440\u0438\u0432\u044b\u0447\u043d\u044b\u0439 <b>datetime.datetime<\/b> \u043f\u0438\u0442\u043e\u043d\u0430 \u0432 <b>boost::posix_time::ptime<\/b> \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 Boost \u0438 \u043e\u0431\u0440\u0430\u0442\u043d\u043e, \u0434\u0430 \u0447\u0451\u0440\u0442 \u0441 \u043d\u0438\u043c, \u043c\u044b \u0432\u043e\u043e\u0431\u0449\u0435 \u0432\u0441\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 datetime \u043f\u0440\u0435\u0432\u0440\u0430\u0442\u0438\u043c \u0432 \u0431\u0443\u0441\u0442\u043e\u0432\u044b\u0435 \u0442\u0438\u043f\u044b! \u0410 \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u0431\u044b\u043b\u043e \u0441\u043a\u0443\u0447\u043d\u043e, \u043f\u0440\u0438\u043d\u0435\u0441\u0451\u043c \u0432 \u0436\u0435\u0440\u0442\u0432\u0443 \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u0431\u0430\u0439\u0442 Python 3.x, \u0434\u043b\u044f \u043d\u0435\u0433\u043e \u043a\u0430\u043a \u0440\u0430\u0437 \u0435\u0449\u0451 \u043d\u0435\u0442 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0435\u0440\u0430 \u0432 Boost.Python, \u0430 \u043f\u043e\u0442\u043e\u043c \u0437\u0432\u0435\u0440\u0441\u043a\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u044e \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u0431\u0430\u0439\u0442 \u0432 \u043d\u043e\u0432\u043e\u043c \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0435\u0440\u0435 \u043f\u0438\u0442\u043e\u043d\u043e\u0432\u0441\u043a\u043e\u0433\u043e <b>uuid.UUID<\/b> \u0432 <b>boost::uuids::uuid<\/b>. \u0414\u0430, \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0435\u0440 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0435\u0440\u0435!<br \/>  \u0416\u0430\u0436\u0434\u0435\u0448\u044c \u043a\u0440\u043e\u0432\u0438, \u041a\u043e\u043b\u0438\u0437\u0435\u0439?!..  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-168827","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/168827","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=168827"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/168827\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=168827"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=168827"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=168827"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}