{"id":465250,"date":"2025-06-30T15:01:44","date_gmt":"2025-06-30T15:01:44","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=465250"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=465250","title":{"rendered":"<span>\u041a\u0430\u043a \u044f \u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u0443\u044e \u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u044e \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0435 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f \u0434\u043b\u044f Python \u043d\u0430 Rust<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-1\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\"><a href=\"https:\/\/habr.com\/ru\/companies\/piter\/articles\/923438\/\"><\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/oa\/t8\/sy\/oat8syxv3fulszrclawkrkdgbfq.png\" sizes=\"(max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/webt\/oa\/t8\/sy\/oat8syxv3fulszrclawkrkdgbfq.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/webt\/oa\/t8\/sy\/oat8syxv3fulszrclawkrkdgbfq.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/div>\n<p><\/a><br \/> \u0412\u044b, \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e, \u0443\u0436\u0435 \u0432\u0438\u0434\u0435\u043b\u0438 \u043d\u0435\u043c\u0430\u043b\u043e \u0441\u0442\u0430\u0442\u0435\u0439 \u0441 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0430\u043c\u0438 \u0432\u0440\u043e\u0434\u0435 \u00abPython, Rust \u2014 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c, \u0431\u043b\u0430-\u0431\u043b\u0430-\u0431\u043b\u0430\u2026\u00bb. \u041f\u0435\u0447\u0430\u043b\u044c\u043d\u043e, \u043d\u043e \u043f\u043e\u0447\u0442\u0438 \u0432\u0441\u0435 \u044d\u0442\u0438 \u0441\u0442\u0430\u0442\u044c\u0438 \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u0443\u044e\u0442 \u043b\u0438\u0448\u044c \u0441\u0430\u043c\u044b\u0435 \u043f\u0440\u043e\u0441\u0442\u044b\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u0443\u0440\u043e\u0432\u043d\u044f \u00abhello world\u00bb. \u0412 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 \u043d\u0438\u0445, \u0432 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u0445\u043e\u0447\u0443 \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0442\u0435\u043c, \u043a\u0430\u043a \u044f \u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u0443\u044e \u043a\u0440\u0443\u043f\u043d\u044b\u0435 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432 \u0438 \u043f\u043e\u0447\u0435\u043c\u0443 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u044e \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0442\u0435 \u0438\u043b\u0438 \u0438\u043d\u044b\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u044f.<a name=\"habracut\"><\/a><\/p>\n<p> \u041d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043b \u0447\u0435\u0442\u044b\u0440\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0434\u043b\u044f Python \u043d\u0430 Rust (<a href=\"https:\/\/github.com\/insight-platform\/FFmpeg-Input\">1<\/a>, <a href=\"https:\/\/github.com\/insight-platform\/Similari\">2<\/a>, <a href=\"https:\/\/github.com\/insight-platform\/savant-rs\">3<\/a>, <a href=\"https:\/\/github.com\/insight-platform\/RocksQ\">4<\/a>) \u0438 \u043f\u0440\u0438\u043e\u0431\u0440\u0451\u043b \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u043f\u044b\u0442, \u043d\u043e \u043d\u0435 \u0447\u0443\u0432\u0441\u0442\u0432\u0443\u044e, \u0447\u0442\u043e \u0434\u043e\u0441\u0442\u0438\u0433 \u0442\u043e\u0433\u043e \u0443\u0440\u043e\u0432\u043d\u044f, \u0447\u0442\u043e\u0431\u044b \u0443\u0442\u0432\u0435\u0440\u0436\u0434\u0430\u0442\u044c, \u0447\u0442\u043e \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e, \u0430 \u0447\u0442\u043e \u043d\u0435\u0442. \u041d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u0437 \u043c\u043e\u0438\u0445 \u043f\u043e\u0434\u0445\u043e\u0434\u043e\u0432 \u0432\u0434\u043e\u0445\u043d\u043e\u0432\u043b\u0435\u043d\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u043c\u0438 \u0434\u0440\u0443\u0433\u0438\u0445, \u0434\u0440\u0443\u0433\u0438\u0435 \u2014 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u0438 \u0440\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u043d\u0433\u0430 \u043a\u043e\u0434\u0430, \u0438 \u0432\u0441\u0451 \u0436\u0435 \u044f \u043d\u0435 \u0443\u0432\u0435\u0440\u0435\u043d, \u0447\u0442\u043e \u044d\u0442\u043e \u043b\u0443\u0447\u0448\u0438\u0439 \u043f\u0443\u0442\u044c \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 Rust \u0438 Python.<\/p>\n<p> \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u044f \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u043e\u043f\u044b\u0442\u043d\u044b\u0439 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a Rust, \u0442\u0430\u043a \u0447\u0442\u043e \u043c\u043e\u0439 \u043a\u043e\u0434 \u043c\u043e\u0436\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u0438\u0447\u0443\u0434\u044b \u2014 \u0431\u0443\u0434\u044c\u0442\u0435 \u0433\u043e\u0442\u043e\u0432\u044b.<\/p>\n<h3>\u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u043d\u043e\u0441\u0442\u0438<\/h3>\n<p> \u0415\u0441\u043b\u0438 \u0432\u044b \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u0442\u0435 \u043c\u043e\u0438 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438, \u0442\u043e \u0443\u0432\u0438\u0434\u0438\u0442\u0435 \u044d\u0432\u043e\u043b\u044e\u0446\u0438\u044e \u043c\u043e\u0435\u0433\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0430 \u043a \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0439 \u043d\u0430 Rust \u0434\u043b\u044f Python: \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043c\u043d\u043e\u0433\u0438\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 <a href=\"https:\/\/github.com\/insight-platform\/Similari\">Similari<\/a> \u0441\u0442\u0440\u0430\u043d\u043d\u044b\u0435, \u043e\u0434\u043d\u0430\u043a\u043e \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043f\u0440\u043e\u0433\u0440\u0435\u0441\u0441 \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u0451\u043b \u043f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u044f \u043f\u043e\u043b\u0443\u0447\u0438\u043b \u0432\u043a\u043b\u0430\u0434 \u043e\u0442 <a href=\"https:\/\/github.com\/andreytkachenko\">\u0410\u043d\u0434\u0440\u0435\u044f \u0422\u043a\u0430\u0447\u0435\u043d\u043a\u043e<\/a>. \u0415\u0449\u0451 \u043e\u0434\u043d\u0430 \u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u043f\u043e\u043a\u0430\u0437\u0430\u043b\u0430, \u043a\u0430\u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c Sphinx \u0434\u043b\u044f \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0439, \u0438 \u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043b \u043e\u0431 \u044d\u0442\u043e\u043c \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0439 <a href=\"https:\/\/medium.com\/inside-in-sight\/documenting-native-python-extensions-made-with-rust-and-pyo3-227aff68e481\">\u0441\u0442\u0430\u0442\u044c\u0435<\/a>. \u042f \u043f\u0440\u043e\u0432\u0451\u043b \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0447\u0430\u0441\u043e\u0432 \u0437\u0430 \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u0435\u043c \u0441\u0440\u0435\u0434\u044b Manylinux, \u0447\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u043b\u043e \u043c\u043d\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c <a href=\"https:\/\/medium.com\/inside-in-sight\/building-portable-native-python-extensions-with-rust-pyo3-and-maturin-3c1a1634d324\">\u0441\u0442\u0430\u0442\u044c\u044e<\/a> \u0441 \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u0435\u0439, \u043a\u0430\u043a \u0441\u043e\u0431\u0438\u0440\u0430\u0442\u044c \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u0438\u043c\u044b\u0435 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f \u043d\u0430 Rust \u0434\u043b\u044f Python \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e GitHub CI \u0438 Docker.<\/p>\n<p> \u0425\u043e\u0447\u0443 \u0441\u043a\u0430\u0437\u0430\u0442\u044c \u00ab\u0441\u043f\u0430\u0441\u0438\u0431\u043e\u00bb \u0432\u0441\u0435\u043c, \u043a\u0442\u043e \u043f\u043e\u043c\u043e\u0433\u0430\u043b \u043c\u043d\u0435 \u043f\u0440\u043e\u0434\u0432\u0438\u0433\u0430\u0442\u044c\u0441\u044f \u0432 \u044d\u0442\u043e\u0439 \u0442\u0435\u043c\u0435: \u043a\u0430\u0436\u0434\u044b\u0439 \u0438\u0437 \u0432\u0430\u0441 \u043f\u0440\u043e\u0434\u0435\u043b\u0430\u043b \u043e\u0433\u0440\u043e\u043c\u043d\u0443\u044e \u0440\u0430\u0431\u043e\u0442\u0443, \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u044f \u0441\u0432\u043e\u0439 \u043a\u043e\u0434 \u0431\u0435\u0437 \u0448\u0438\u0440\u043e\u043a\u043e \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u0445 \u043f\u043e\u0434\u0445\u043e\u0434\u043e\u0432 \u0438 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0439 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438.<\/p>\n<p> \u041c\u043e\u044f \u0431\u043e\u043b\u044c\u0448\u0430\u044f \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u043d\u043e\u0441\u0442\u044c: <\/p>\n<ul>\n<li><a href=\"https:\/\/github.com\/PyO3\/pyo3\">\u041a\u043e\u043c\u0430\u043d\u0434\u0435<\/a> PyO3 \u2014 \u0437\u0430 \u0438\u0445 \u0443\u0441\u0438\u043b\u0438\u044f \u043f\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044e \u043e\u0442\u043b\u0438\u0447\u043d\u043e\u0433\u043e \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430 \u0434\u043b\u044f \u043f\u043b\u0430\u0432\u043d\u043e\u0439 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0439;<\/li>\n<li><a href=\"https:\/\/github.com\/andreytkachenko\">\u0410\u043d\u0434\u0440\u0435\u044e \u0422\u043a\u0430\u0447\u0435\u043d\u043a\u043e<\/a> \u2014 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u043a\u0430\u0437\u0430\u043b, \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c transmute \u043f\u0440\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0439 Python \u043d\u0430 Rust, \u0438 \u0437\u0430 \u0435\u0433\u043e \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0432\u043a\u043b\u0430\u0434 \u0432 <a href=\"https:\/\/github.com\/insight-platform\/Similari\">Similari<\/a>;<\/li>\n<li><a href=\"https:\/\/www.pola.rs\/\">\u041a\u043e\u043c\u0430\u043d\u0434\u0435<\/a> \u043f\u0440\u043e\u0435\u043a\u0442\u0430 Pola.rs \u2014 \u0437\u0430 \u0438\u0434\u0435\u0438 \u043f\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044e \u0438 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u044b \u043a\u043e\u0434\u0430;<\/li>\n<li><a href=\"https:\/\/github.com\/Pometry\/Raphtory\">\u041a\u043e\u043c\u0430\u043d\u0434\u0435<\/a> Pometry\/Raphtory \u2014 \u0437\u0430 \u0438\u0445 \u0438\u0434\u0435\u0438 \u043f\u043e \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044e \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0439 Python \u043d\u0430 Rust.<\/li>\n<\/ul>\n<p> <\/p>\n<h3>\u041f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u044f<\/h3>\n<p> \u042d\u0442\u043e \u043d\u0435 \u0432\u0432\u043e\u0434\u043d\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f. \u042f \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u044e, \u0447\u0442\u043e \u0432\u044b \u0437\u043d\u0430\u043a\u043e\u043c\u044b \u0441 Rust \u0438 \u0443\u043c\u0435\u0435\u0442\u0435 \u043f\u0438\u0441\u0430\u0442\u044c \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 \u0434\u043b\u044f Python \u043d\u0430 Rust \u0443\u0440\u043e\u0432\u043d\u044f \u00abhello world\u00bb \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c PyO3. \u0422\u0430\u043a\u0436\u0435 \u044f \u0441\u0447\u0438\u0442\u0430\u044e, \u0447\u0442\u043e \u0432\u044b \u0437\u043d\u0430\u0435\u0442\u0435, \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0435 GIL \u0438 \u043a\u0430\u043a \u043e\u043d \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442.<\/p>\n<h3>\u041e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0438 \u043c\u043e\u0434\u0435\u043b\u0438 \u043f\u0430\u043c\u044f\u0442\u0438<\/h3>\n<p> Rust \u0438 Python \u0438\u043c\u0435\u044e\u0442 \u0440\u0430\u0437\u043d\u044b\u0435 \u043c\u043e\u0434\u0435\u043b\u0438 \u043f\u0430\u043c\u044f\u0442\u0438, \u0447\u0442\u043e \u0443\u0441\u043b\u043e\u0436\u043d\u044f\u0435\u0442 \u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043a\u043e\u043c\u043f\u043b\u0435\u043a\u0441\u043d\u044b\u0445 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440: \u0432 Rust \u043c\u043e\u0434\u0435\u043b\u044c \u043f\u0430\u043c\u044f\u0442\u0438 \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u0430 \u043d\u0430 \u0432\u043b\u0430\u0434\u0435\u043d\u0438\u0438 (ownership), \u0430 \u0432 Python \u2014 \u043d\u0430 \u0441\u0441\u044b\u043b\u043a\u0430\u0445 \u043d\u0430 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0432 \u043a\u0443\u0447\u0435. \u0411\u043b\u0438\u0436\u0430\u0439\u0448\u0430\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430, \u043e\u0442\u0440\u0430\u0436\u0430\u044e\u0449\u0430\u044f \u043c\u043e\u0434\u0435\u043b\u044c \u043f\u0430\u043c\u044f\u0442\u0438 Python \u0432 Rust, \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<\/p>\n<pre><code class=\"python\">Arc&lt;Mutex&lt;Object&gt;&gt;<\/code><\/pre>\n<p> \u041d\u043e \u0432 Python \u043c\u044c\u044e\u0442\u0435\u043a\u0441\u043e\u043c \u0432\u044b\u0441\u0442\u0443\u043f\u0430\u0435\u0442 GIL. \u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043d\u0435\u043b\u044c\u0437\u044f \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0438\u0437 Rust \u0432 Python \u0441\u0441\u044b\u043b\u043a\u0443 (<code>&amp;mut<\/code> \u0438\u043b\u0438 <code>&amp;<\/code>) \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u2014 \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/sa\/iv\/qf\/saivqfpzf6j2leareg9ckgve4jk.png\" sizes=\"(max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/webt\/sa\/iv\/qf\/saivqfpzf6j2leareg9ckgve4jk.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/webt\/sa\/iv\/qf\/saivqfpzf6j2leareg9ckgve4jk.png 781w\" loading=\"lazy\" decode=\"async\"\/>. PyO3 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u044f, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442\u044b, \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0435 Python, \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 Rust \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435, \u043d\u043e \u043e\u0431\u0440\u0430\u0442\u043d\u0443\u044e \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043d\u0435\u043b\u044c\u0437\u044f: \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 Rust-\u043e\u0431\u044a\u0435\u043a\u0442 \u0432\u043d\u0443\u0442\u0440\u0438 Python-\u043e\u0431\u044a\u0435\u043a\u0442\u0430. PyO3 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0443 Rust-\u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0432 Python \u043f\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044e, \u043e\u0431\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u044f \u0438\u0445 \u0432 \u043e\u0431\u044a\u0435\u043a\u0442\u044b Python.<\/p>\n<p> \u042d\u0442\u043e \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u0432\u0430\u0436\u043d\u043e \u0434\u043b\u044f \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u043e\u0434\u0430, \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0435\u0441\u043b\u0438 \u043e\u043d \u043e\u0441\u0432\u043e\u0431\u043e\u0436\u0434\u0430\u0435\u0442 GIL, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043e\u0441\u0432\u043e\u0431\u043e\u0436\u0434\u0435\u043d\u0438\u0435 GIL \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u043e\u0442 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 <code>Ungil<\/code>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f, <a href=\"https:\/\/github.com\/PyO3\/pyo3\/blob\/b03c4cb33cc30da738270a4db8322d5d9b74fb8c\/src\/marker.rs#L182\">\u043f\u043e \u0441\u0443\u0442\u0438<\/a>, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f <code>Send<\/code>.<\/p>\n<p> \u0415\u0441\u043b\u0438 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442 \u043c\u0435\u0436\u0434\u0443 Python \u0438 Rust, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u0431\u0451\u0440\u0442\u043a\u0443 \u0434\u043b\u044f <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/sa\/iv\/qf\/saivqfpzf6j2leareg9ckgve4jk.png\" sizes=\"(max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/webt\/sa\/iv\/qf\/saivqfpzf6j2leareg9ckgve4jk.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/webt\/sa\/iv\/qf\/saivqfpzf6j2leareg9ckgve4jk.png 781w\" loading=\"lazy\" decode=\"async\"\/> \u0438\u043b\u0438 <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/l-\/yf\/0r\/l-yf0rvcjeexncjpaztuf70bbbk.png\" sizes=\"(max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/webt\/l-\/yf\/0r\/l-yf0rvcjeexncjpaztuf70bbbk.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/webt\/l-\/yf\/0r\/l-yf0rvcjeexncjpaztuf70bbbk.png 781w\" loading=\"lazy\" decode=\"async\"\/>.<\/p>\n<p> \u041f\u0440\u0438\u043c\u0435\u0440 \u043e\u0431\u044a\u0435\u043a\u0442\u0430, \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0433\u043e Python \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u043e\u0433\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0438\u0437 Python:<\/p>\n<pre><code class=\"python\">use pyo3::prelude::*;  #[pyclass] struct Object {     x: i32, }  #[pymethods] impl Object {     fn inc(&amp;mut self) {         self.x += 1;     } }<\/code><\/pre>\n<p> \u0421\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0431\u044a\u0435\u043a\u0442 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u0430 \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u044e Rust, \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c\u0443\u044e \u0438\u0437 Python, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0442\u0430\u043a:<\/p>\n<pre><code class=\"python\">#[pyfunction] fn callme(o: &amp;mut Object) {     o.inc(); }<\/code><\/pre>\n<p> \u041f\u0440\u0438\u043c\u0435\u0440 \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0438\u0437 Rust \u0438 Python:<\/p>\n<pre><code class=\"python\">use parking_lot::Mutex; use pyo3::prelude::*; use std::sync::Arc;  struct Object {     x: i32, }  impl Object {     fn inc(&amp;mut self) {         self.x += 1;     } }  #[pyclass] #[pyo3(name = \"Object\")] #[derive(Clone)] struct ObjectWrapper(Arc&lt;Mutex&lt;Object&gt;&gt;);  #[pymethods] impl ObjectWrapper {     fn inc(&amp;self) {         let mut bound = self.0.lock();         bound.inc();     } }<\/code><\/pre>\n<p> \u0422\u0435\u043f\u0435\u0440\u044c \u0443 \u0432\u0430\u0441 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 \u043e\u0434\u0438\u043d \u0438 \u0442\u043e\u0442 \u0436\u0435 \u043e\u0431\u044a\u0435\u043a\u0442 \u043a\u0430\u043a \u0432 Python, \u0442\u0430\u043a \u0438 \u0432 Rust, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440<\/p>\n<pre><code class=\"python\">thread_local! {     static OBJECT: ObjectWrapper = ObjectWrapper(Arc::new(Mutex::new(Object { x: 0 }))) }  #[pyfunction] fn shared_object() -&gt; ObjectWrapper {     OBJECT.with(|o| o.clone()) }  #[pyfunction] fn callme(o: &amp;mut ObjectWrapper) {     o.inc(); }<\/code><\/pre>\n<p> \u041e\u0431\u044a\u0435\u043a\u0442 \u043c\u043e\u0436\u0435\u0442 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u0438\u0437 Python \u0438 Rust. \u0414\u043b\u044f \u0437\u0430\u0449\u0438\u0442\u044b \u043e\u0442 \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u043e\u0432\u0435\u043d\u0438\u044f \u0433\u043e\u043d\u043a\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/ku\/vg\/al\/kuvgaljic2mqv6nekfw_vekx3iy.png\" sizes=\"(max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/webt\/ku\/vg\/al\/kuvgaljic2mqv6nekfw_vekx3iy.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/webt\/ku\/vg\/al\/kuvgaljic2mqv6nekfw_vekx3iy.png 781w\" loading=\"lazy\" decode=\"async\"\/>, \u0430 <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/sa\/iv\/qf\/saivqfpzf6j2leareg9ckgve4jk.png\" sizes=\"(max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/webt\/sa\/iv\/qf\/saivqfpzf6j2leareg9ckgve4jk.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/webt\/sa\/iv\/qf\/saivqfpzf6j2leareg9ckgve4jk.png 781w\" loading=\"lazy\" decode=\"async\"\/> \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u0435\u0442 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u043d\u043e\u0433\u043e \u0434\u043e\u0441\u0442\u0443\u043f\u0430. \u0412\u043c\u0435\u0441\u0442\u043e \u043c\u044c\u044e\u0442\u0435\u043a\u0441\u0430 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u0440\u0443\u0433\u0438\u0435 \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u044b \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u0438, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <code>RwLock<\/code>.<\/p>\n<p> \u0412 Python \u043d\u0435\u043b\u044c\u0437\u044f \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0449\u0443\u044e \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u043e\u0431\u044a\u0435\u043a\u0442, \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0439 \u0432 Rust. \u041e\u0434\u043d\u0430\u043a\u043e \u043c\u043e\u0436\u043d\u043e \u0432\u0435\u0440\u043d\u0443\u0442\u044c \u0441\u0441\u044b\u043b\u043a\u0443 Python \u043d\u0430 \u043e\u0431\u044a\u0435\u043a\u0442, \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0439 \u0432 \u043f\u0430\u043c\u044f\u0442\u0438 Python:<\/p>\n<pre><code class=\"python\">fn callme&lt;'p&gt;(slf: PyRef&lt;'p, Self&gt;, _py: Python&lt;'p&gt;) -&gt; PyResult&lt;PyRef&lt;'p, Self&gt;&gt; {     let o = slf.deref();     ...     Ok(slf)     <\/code><\/pre>\n<p> \u042f \u043d\u0435 \u0447\u0430\u0441\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b \u043f\u0440\u0438\u0432\u0435\u0434\u0451\u043d\u043d\u044b\u0439 \u0432\u044b\u0448\u0435 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441, \u043d\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u043b \u0435\u0433\u043e \u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u0445 \u0434\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f <code>with<\/code> \u0432 Python \u0434\u043b\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432.<\/p>\n<h3>\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u0430<\/h3>\n<p> \u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0441\u0438\u043b\u044c\u043d\u043e \u0432\u043b\u0438\u044f\u0435\u0442 \u043d\u0430 \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u044c \u0438 \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u043e \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043a\u043e\u0434\u043e\u043c \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 PyO3. \u041e\u0431\u044b\u0447\u043d\u043e, \u0438\u0437\u0443\u0447\u0438\u0432 \u0434\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u043e \u043f\u043e PyO3, \u0432\u044b \u0441\u043e\u0437\u0434\u0430\u0451\u0442\u0435 \u043f\u0440\u043e\u0435\u043a\u0442, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c Rust-\u043a\u043e\u0434 \u0442\u0435\u0441\u043d\u043e \u0441\u0432\u044f\u0437\u0430\u043d \u0441 Python-\u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u044f\u043c\u0438 \u2014 \u0438\u0437-\u0437\u0430 \u044d\u0442\u043e\u0433\u043e \u043a\u043e\u0434 \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0431\u0435\u0437 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u043e\u0433\u043e Python \u0438 \u043f\u0440\u043e\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0431\u0435\u0437 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 Python-\u0440\u0430\u043d\u0442\u0430\u0439\u043c\u0430.<\/p>\n<p> \u0412 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0435, \u0443 \u0432\u0430\u0441 \u0435\u0441\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u043e\u0432 \u043a \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044e \u043a\u043e\u0434\u0430: <\/p>\n<ul>\n<li>\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0430 \u0438\u043c\u0451\u043d \u0438 \u0444\u0438\u0447\u0435-\u0444\u043b\u0430\u0433\u0438, \u043f\u043e\u043c\u0435\u0449\u0430\u044f \u043a\u043e\u0434, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0439 \u0441 Python, \u0437\u0430 \u0444\u043b\u0430\u0433\u0430\u043c\u0438 (\u044d\u0442\u043e\u0442 \u043f\u043e\u0434\u0445\u043e\u0434 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d \u0432 <a href=\"https:\/\/github.com\/insight-platform\/Similari\">Similari<\/a>);<\/li>\n<li>\u0441 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u043c\u0438 \u043a\u0440\u0435\u0439\u0442\u0430\u043c\u0438, \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u043d\u044b\u043c\u0438 \u0432 \u043e\u0434\u043d\u043e \u0440\u0430\u0431\u043e\u0447\u0435\u0435 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e (<a href=\"https:\/\/github.com\/insight-platform\/savant-rs\">Savant-RS<\/a>, <a href=\"https:\/\/github.com\/insight-platform\/RocksQ\">RocksQ<\/a>).<\/li>\n<\/ul>\n<p> \u0418\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u044f \u043f\u0440\u0438\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u043b\u0441\u044f \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0430, \u043d\u043e \u0441\u0435\u0439\u0447\u0430\u0441 \u0441\u0447\u0438\u0442\u0430\u044e, \u0447\u0442\u043e \u0432\u0442\u043e\u0440\u043e\u0439 \u043d\u0430\u043c\u043d\u043e\u0433\u043e \u043b\u0443\u0447\u0448\u0435.<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/ab\/ld\/dx\/ablddx7eaovtvg6sy9y6dbnzzsw.png\" alt=\"image\" sizes=\"(max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/webt\/ab\/ld\/dx\/ablddx7eaovtvg6sy9y6dbnzzsw.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/webt\/ab\/ld\/dx\/ablddx7eaovtvg6sy9y6dbnzzsw.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/div>\n<p> \u0418\u0442\u0430\u043a, \u043a\u0430\u043a \u0432\u0438\u0434\u0438\u0442\u0435, \u0443 \u043c\u0435\u043d\u044f \u0435\u0441\u0442\u044c \u0434\u0432\u0430 \u043f\u0430\u043a\u0435\u0442\u0430 Rust (\u043a\u0440\u0435\u0439\u0442\u0430): \u0432 <code>queue_rs<\/code> \u044f \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043b \u043b\u043e\u0433\u0438\u043a\u0443 \u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c; \u043e\u043d \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0437\u043d\u0430\u0435\u0442 \u043e Python. \u0412\u043e \u0432\u0442\u043e\u0440\u043e\u043c \u0435\u0441\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043a\u043e\u0434, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0439 \u0441 Python.<\/p>\n<p> \u042f \u0441\u0447\u0438\u0442\u0430\u044e, \u0447\u0442\u043e \u0442\u0430\u043a\u0430\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u2014 \u043d\u0430\u0438\u043b\u0443\u0447\u0448\u0430\u044f, \u0438 \u043d\u0430 \u0442\u043e \u0435\u0441\u0442\u044c \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u043f\u0440\u0438\u0447\u0438\u043d. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0438\u0445 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c.<\/p>\n<p> <b>\u041f\u0440\u043e\u0434\u0443\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u043b\u043e\u0433\u0438\u043a\u043e\u0439 \u043d\u0430 Rust.<\/b> \u042f \u0445\u043e\u0447\u0443, \u0447\u0442\u043e\u0431\u044b \u043c\u043e\u0439 \u043a\u043e\u0434 \u0431\u044b\u0441\u0442\u0440\u043e \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043b\u0441\u044f \u0438 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043b\u0441\u044f \u0431\u0435\u0437 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0442\u044c Python-\u0440\u0430\u043d\u0442\u0430\u0439\u043c \u0438 \u0435\u0433\u043e \u0442\u0438\u043f\u044b \u0434\u0430\u043d\u043d\u044b\u0445. \u0422\u0430\u043a\u0430\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u0438\u0440\u0430\u0442\u044c \u043a\u043e\u0434, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430\u0442\u0438\u0432\u043d\u044b\u0435 \u0442\u0438\u043f\u044b Rust.<\/p>\n<p> \u0417\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c \u043e\u0442 PyO3 \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0435\u0442 \u0432\u0440\u0435\u043c\u044f \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 \u0438 \u0437\u0430\u0447\u0430\u0441\u0442\u0443\u044e \u0434\u0435\u043b\u0430\u0435\u0442 \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u043c \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0442\u0435\u0441\u0442\u043e\u0432 \u0431\u0435\u0437 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 Python-\u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f.<\/p>\n<blockquote><p><i>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 <code>PyBytes<\/code> \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0440\u0430\u0431\u043e\u0447\u0435\u0435 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u0435 Python, \u0447\u0442\u043e\u0431\u044b \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442 \u044d\u0442\u043e\u0433\u043e \u0442\u0438\u043f\u0430. \u042f \u043d\u0435 \u0445\u043e\u0447\u0443 \u0438\u043c\u0435\u0442\u044c \u0434\u0435\u043b\u043e \u0441 \u0442\u0430\u043a\u0438\u043c\u0438 \u0438\u0437\u0431\u044b\u0442\u043e\u0447\u043d\u044b\u043c\u0438 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f\u043c\u0438, \u043a\u043e\u0433\u0434\u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u044e \u043d\u0430\u0434 \u043b\u043e\u0433\u0438\u043a\u043e\u0439.<\/i><\/p><\/blockquote>\n<p> \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u043f\u0438\u0448\u0443 \u043a\u043e\u0434 \u0441 \u0443\u0447\u0451\u0442\u043e\u043c \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0435\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 \u043f\u0430\u043c\u044f\u0442\u0438, \u043d\u043e \u0431\u0435\u0437 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f Python-\u0441\u043f\u0435\u0446\u0438\u0444\u0438\u0447\u043d\u044b\u0445 \u0442\u0438\u043f\u043e\u0432 \u0438 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 PyO3.<\/p>\n<p> \u041c\u043e\u0438 \u0431\u0435\u043d\u0447\u043c\u0430\u0440\u043a\u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0441 \u043a\u043e\u0434\u043e\u043c \u043d\u0430 Rust, \u0442\u0430\u043a \u0447\u0442\u043e \u044f \u0442\u043e\u0447\u043d\u043e \u0437\u043d\u0430\u044e \u2014 \u043e\u043d\u0438 \u0438\u0437\u043c\u0435\u0440\u044f\u044e\u0442 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u044c \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430, \u0430 \u043d\u0435 \u043d\u0430\u043a\u043b\u0430\u0434\u043d\u044b\u0435 \u0440\u0430\u0441\u0445\u043e\u0434\u044b.<\/p>\n<p> \u041e\u0434\u043d\u0430\u0436\u0434\u044b \u044d\u0442\u043e \u043f\u043e\u043c\u043e\u0433\u043b\u043e \u043c\u043d\u0435 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u0442\u044c, \u0447\u0442\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0430 \u0432 Rust <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/br\/mr\/ts\/brmrtsnnhm2w2szgvdnaeypjspg.png\" sizes=\"(max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/webt\/br\/mr\/ts\/brmrtsnnhm2w2szgvdnaeypjspg.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/webt\/br\/mr\/ts\/brmrtsnnhm2w2szgvdnaeypjspg.png 781w\" loading=\"lazy\" decode=\"async\"\/> \u0441\u0438\u043b\u044c\u043d\u043e \u0441\u043d\u0438\u0436\u0430\u0435\u0442 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432 \u043a\u043e\u0434\u0435, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u043e\u043c \u0441 PyO3, \u044f \u043d\u0430\u0447\u0430\u043b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <code>PyBytes<\/code>.<\/p>\n<p> <b>\u041f\u0440\u043e\u0434\u0443\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u043a\u043e\u0434\u043e\u043c, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u043c \u0441 Python.<\/b> \u041a\u043e\u0433\u0434\u0430 \u044f \u0437\u0430\u043d\u0438\u043c\u0430\u044e\u0441\u044c Python-\u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0435\u0439, \u043c\u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043c\u0435\u0436\u0434\u0443 \u0442\u0438\u043f\u0430\u043c\u0438 Python, \u0430 \u043d\u0435 \u043e\u0441\u043d\u043e\u0432\u043d\u0443\u044e \u043b\u043e\u0433\u0438\u043a\u0443. \u0412\u0440\u0435\u043c\u044f \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 \u0441\u043e\u043a\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u043e\u0441\u0442\u0430\u0451\u0442\u0441\u044f \u043d\u0435\u0438\u0437\u043c\u0435\u043d\u043d\u043e\u0439. <\/p>\n<blockquote><p><i>\u041e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u044f \u0440\u0430\u0437\u0434\u0440\u0430\u0436\u0430\u0435\u0442 \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u043d\u0430\u0434 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0435\u0439 \u2014 \u044f \u0447\u0430\u0441\u0442\u043e \u043c\u0435\u043d\u044f\u044e \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438 \u0438 \u043f\u0435\u0440\u0435\u0441\u043e\u0431\u0438\u0440\u0430\u044e \u043a\u043e\u0434. \u041c\u043e\u0438 \u043d\u0430\u0431\u043b\u044e\u0434\u0435\u043d\u0438\u044f \u043f\u043e \u0441\u0431\u043e\u0440\u043a\u0435 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u0434\u043b\u044f Rust-\u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0439 \u043e\u043f\u0438\u0441\u0430\u043d\u044b \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0439 <a href=\"https:\/\/medium.com\/inside-in-sight\/documenting-native-python-extensions-made-with-rust-and-pyo3-227aff68e481\">\u0441\u0442\u0430\u0442\u044c\u0435<\/a>. \u041f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u043c\u0430\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0441\u043e\u043a\u0440\u0430\u0442\u0438\u0442\u044c \u0432\u0440\u0435\u043c\u044f \u0441\u0431\u043e\u0440\u043a\u0438.<\/i><\/p><\/blockquote>\n<p> <b>\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043a\u043e\u0434\u043e\u0432\u043e\u0439 \u0431\u0430\u0437\u044b.<\/b> \u042f \u0432\u0441\u0435\u0433\u0434\u0430 \u0437\u043d\u0430\u044e, \u0433\u0434\u0435 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043d\u0443\u0436\u043d\u044b\u0439 \u043a\u043e\u0434: \u0435\u0441\u043b\u0438 \u043e\u043d \u0441\u0432\u044f\u0437\u0430\u043d \u0441 Python \u2014 \u043e\u043d \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 <code>*_py<\/code>, \u0435\u0441\u043b\u0438 \u043d\u0435\u0442 \u2014 \u0432 <code>*_rs<\/code>. \u042d\u0442\u043e \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u0445\u0430\u043e\u0441\u0430, \u043a\u043e\u0433\u0434\u0430 \u0432 \u043e\u0434\u043d\u043e\u043c \u0444\u0430\u0439\u043b\u0435 \u0441\u043e\u0441\u0440\u0435\u0434\u043e\u0442\u043e\u0447\u0435\u043d\u043e \u043c\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430, \u043d\u0435 \u043e\u0442\u043d\u043e\u0441\u044f\u0449\u0435\u0433\u043e\u0441\u044f \u043a \u043b\u043e\u0433\u0438\u043a\u0435, \u043d\u043e \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u044e\u0449\u0435\u0433\u043e \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0441 Python.<\/p>\n<p> <b>\u0418\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432.<\/b> \u0412 Rust \u043d\u0435\u0442 \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u043a\u0438 \u0438\u043c\u0451\u043d \u0444\u0443\u043d\u043a\u0446\u0438\u0439, \u0430 \u0437\u043d\u0430\u0447\u0438\u0442, \u0435\u0441\u043b\u0438 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u0438\u043c\u0435\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0438 \u0434\u043b\u044f \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0445 \u043d\u0443\u0436\u0434 (\u0442\u043e\u043b\u044c\u043a\u043e Rust), \u0438 \u0434\u043b\u044f \u044d\u043a\u0441\u043f\u043e\u0440\u0442\u0430 \u0432 Python, \u0432\u0430\u043c \u043f\u0440\u0438\u0434\u0451\u0442\u0441\u044f \u043f\u0440\u0438\u0434\u0443\u043c\u044b\u0432\u0430\u0442\u044c \u043d\u0435\u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0435 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f.<\/p>\n<p> \u0420\u0430\u043d\u0435\u0435 \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u0441\u0445\u0435\u043c\u0443:<\/p>\n<pre><code class=\"python\">fn callme(x: i64) -&gt; i64 { ... }  #[pyfunction] #[pyo3(name = \"callme\")] fn callme_py(x: i64) -&gt; i64 {     callme(x) }<\/code><\/pre>\n<p> \u041e\u043d\u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u043d\u0435\u0440\u044f\u0448\u043b\u0438\u0432\u044b\u0439 \u043a\u043e\u0434. \u0421 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u043c \u043f\u043e\u0434\u0445\u043e\u0434\u043e\u043c \u044d\u0442\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code class=\"python\">use lib_rs as rust;  #[pyfunction] fn callme(x: i64) -&gt; i64 {     rust::callme(x) }<\/code><\/pre>\n<p> <b>\u0420\u0430\u043d\u043e \u0438\u043b\u0438 \u043f\u043e\u0437\u0434\u043d\u043e \u043a\u0442\u043e-\u0442\u043e \u0437\u0430\u0445\u043e\u0447\u0435\u0442 \u0441\u0431\u043e\u0440\u043a\u0443 \u0431\u0435\u0437 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 Python.<\/b> \u042d\u0442\u043e \u0441\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c \u0441 Similari \u2014 \u043f\u043e\u044f\u0432\u0438\u043b\u0438\u0441\u044c \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043d\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043a\u043e\u0434\u0430 \u0431\u0435\u0437 Python. \u042d\u0442\u043e \u0441\u0442\u0430\u043b\u043e \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u043e\u0439. \u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 <a href=\"https:\/\/github.com\/andreytkachenko\">\u0410\u043d\u0434\u0440\u0435\u0439 \u0422\u043a\u0430\u0447\u0435\u043d\u043a\u043e<\/a> \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0438\u043b \u0431\u043e\u043b\u044c\u0448\u043e\u0439 pull request, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u0430\u044f \u0441 Python, \u0431\u044b\u043b\u0430 \u0432\u044b\u043d\u0435\u0441\u0435\u043d\u0430 \u0437\u0430 \u0444\u0438\u0447\u0435-\u0444\u043b\u0430\u0433.<\/p>\n<h3>\u041e\u0431\u0435\u0440\u0442\u043a\u0438 \u0434\u043b\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 Python<\/h3>\n<p> \u0422\u0435\u043f\u0435\u0440\u044c, \u0437\u043d\u0430\u044f \u043c\u043e\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u043f\u0440\u043e\u0435\u043a\u0442\u0430, \u0432\u044b, \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e, \u043d\u0430\u0447\u0430\u043b\u0438 \u0434\u0443\u043c\u0430\u0442\u044c, \u0447\u0442\u043e \u0443 \u043c\u0435\u043d\u044f \u0431\u043e\u043b\u044c\u0448\u0435 \u0434\u0443\u0431\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u043e\u0434\u0430, \u0447\u0435\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e. \u0414\u0430, \u044d\u0442\u043e \u0442\u0430\u043a: \u0432\u043c\u0435\u0441\u0442\u043e \u0430\u043d\u043d\u043e\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043e\u0434\u043d\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>#[pyclass]<\/code>, \u0443 \u043c\u0435\u043d\u044f \u0434\u0432\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438:<\/p>\n<pre><code class=\"python\">pub struct Object {     x: i32, }  impl Object {     pub fn inc(&amp;mut self) {         self.x += 1;     } }<\/code><\/pre>\n<p> <\/p>\n<pre><code class=\"python\">use pyo3::prelude::*; use lib_rs as rust;  #[pyclass] struct Object(rust::Object);  #[pymethods] impl Object {     fn inc(&amp;mut self) {         self.0.inc()     } }<\/code><\/pre>\n<p> \u0422\u0435\u043c \u043d\u0435 \u043c\u0435\u043d\u0435\u0435, \u044f \u0441\u0447\u0438\u0442\u0430\u044e \u0442\u0430\u043a\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043e\u0447\u0435\u043d\u044c \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u043c, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043a\u043e\u0434 \u0432 \u043a\u0440\u0435\u0439\u0442\u0430\u0445 <code>*_py<\/code> \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u0447\u0438\u0441\u0442\u044b\u0439 \u0448\u0430\u0431\u043b\u043e\u043d \u0438 \u043b\u0435\u0433\u043a\u043e \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e GitHub Copilot \u043f\u043e\u0447\u0442\u0438 \u0431\u0435\u0437 \u043e\u0448\u0438\u0431\u043e\u043a.<\/p>\n<p> <b>\u041e\u0431\u0451\u0440\u0442\u043a\u0430 \u0434\u043b\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u0430 Python \u2014 \u044d\u0442\u043e \u043a\u043e\u0440\u0442\u0435\u0436\u043d\u0430\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0441 \u043e\u0434\u043d\u0438\u043c \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u043c<\/b><br \/> \u041e\u0431\u044b\u0447\u043d\u043e \u044f \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e \u0442\u0440\u0430\u0434\u0438\u0446\u0438\u043e\u043d\u043d\u044b\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b Rust (struct) \u0432 \u0441\u0432\u043e\u0438\u0445 <code>*_py<\/code> \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445 \u2014 \u0442\u043e\u043b\u044c\u043a\u043e \u043a\u043e\u0440\u0442\u0435\u0436\u043d\u044b\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b. \u0420\u0430\u043d\u0435\u0435 \u044f \u043f\u0438\u0441\u0430\u043b \u0447\u0442\u043e-\u0442\u043e \u0432\u0440\u043e\u0434\u0435:<\/p>\n<pre><code class=\"python\">struct Object {     inner: rust::Object }<\/code><\/pre>\n<p> \u041e\u0434\u043d\u0430\u043a\u043e \u0441\u0435\u0439\u0447\u0430\u0441 \u044f \u0432\u0438\u0436\u0443 \u0438 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u0438 \u0442\u0430\u043a\u043e\u0433\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0430: <\/p>\n<ul>\n<li>\u0418\u043d\u043e\u0433\u0434\u0430 \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e inner, \u0438\u043d\u043e\u0433\u0434\u0430 \u2014 object, internal \u0438 \u0442.\u0434. \u042d\u0442\u043e \u0432\u043d\u043e\u0441\u0438\u0442 \u0445\u0430\u043e\u0441.<\/li>\n<li>\u041a\u043e\u0434 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043c\u0435\u043d\u0435\u0435 \u043e\u0434\u043d\u043e\u0440\u043e\u0434\u043d\u044b\u043c, \u0432\u0435\u0434\u044c \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u043a\u043e\u0440\u0442\u0435\u0436\u043d\u044b\u0445 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440 \u0432\u0441\u0435\u0433\u0434\u0430 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043e\u0431\u0440\u0430\u0449\u0430\u0442\u044c\u0441\u044f \u0447\u0435\u0440\u0435\u0437 <code>.0.<\/code><\/li>\n<li>\u0421 \u0442\u0430\u043a\u0438\u043c\u0438 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430\u043c\u0438 \u043b\u0435\u0433\u043a\u043e (\u0438 \u043d\u0435\u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e) \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u044c <code>std::mem::transmute<\/code> \ud83d\udc7f.<\/li>\n<li>\u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u0443\u044e \u043e\u0431\u0435\u0440\u0442\u043a\u0443 \u0434\u043b\u044f \u043e\u043f\u0446\u0438\u0439:<\/li>\n<\/ul>\n<pre><code class=\"python\">#[pyfunction] fn callme() -&gt; Option&lt;Object&gt; {     if ... {        None     } else {        let res_opt = Some(rust::Object);        res_opt.map(Object) \/\/ here it is         } }<\/code><\/pre>\n<p> <b>\u041c\u0430\u0433\u0438\u044f transmute.<\/b> \u0412 Rust \u043c\u0430\u043a\u0435\u0442 \u043f\u0430\u043c\u044f\u0442\u0438 \u0434\u043b\u044f \u0442\u0438\u043f\u043e\u0432 <code>X<\/code> \u0438 <code>Y(X)<\/code> \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u0435\u0442, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <code>transmute<\/code> \u0434\u043b\u044f \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0433\u043e \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u043e\u0440\u0442\u0435\u0436\u043d\u044b\u0445 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440 Python \u0432 \u043a\u043e\u0440\u0442\u0435\u0436\u043d\u044b\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b Rust \u0431\u0435\u0437 \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043d\u043e\u0432\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438. \u041e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0442\u043e\u0433\u0434\u0430, \u043a\u043e\u0433\u0434\u0430 \u043d\u0443\u0436\u043d\u043e \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/uh\/4w\/i4\/uh4wi4hglv01arla_va5vezcdce.png\" sizes=\"(max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/webt\/uh\/4w\/i4\/uh4wi4hglv01arla_va5vezcdce.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/webt\/uh\/4w\/i4\/uh4wi4hglv01arla_va5vezcdce.png 781w\" loading=\"lazy\" decode=\"async\"\/> \u043c\u0435\u0436\u0434\u0443 Rust-\u043e\u0431\u044a\u0435\u043a\u0442\u043e\u043c \u0438 Python-\u043e\u0431\u044a\u0435\u043a\u0442\u043e\u043c.<\/p>\n<blockquote><p><i><a href=\"https:\/\/rust-lang.github.io\/unsafe-code-guidelines\/layout\/structs-and-tuples.html#single-field-structs\">\u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435<\/a> \u043e\u0431 \u044d\u0442\u043e\u043c \u0447\u0438\u0442\u0430\u0439\u0442\u0435 \u0432 \u0441\u043f\u0440\u0430\u0432\u043e\u0447\u043d\u0438\u043a\u0435 Unsafe Code Guidelines Reference.<\/i><\/p><\/blockquote>\n<p> \u041d\u0435 \u043f\u043e\u0439\u043c\u0438\u0442\u0435 \u043c\u0435\u043d\u044f \u043d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e, \u044f \u043d\u0435 \u043f\u0440\u043e\u043f\u0430\u0433\u0430\u043d\u0434\u0438\u0440\u0443\u044e <code>transmute<\/code> \u2014 \u044d\u0442\u043e \u043d\u0435\u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f, \u043d\u043e \u043e\u043d\u0430 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043c\u043e\u0447\u044c \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0438\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u043f\u0430\u043c\u044f\u0442\u0438 \u043d\u0430 \u043c\u0435\u0441\u0442\u0435 \u043f\u043e\u0447\u0442\u0438 \u0431\u0435\u0437 \u0437\u0430\u0442\u0440\u0430\u0442.<\/p>\n<pre><code class=\"python\">struct X {   i: i64 }  struct W(X)  let x = X { i: 1 }; let w: W = unsafe { std::mem::transmute(x) }; let x: X = unsafe { std::mem::transmute(w) };  let vx = vec![X { i: 1 }]; let wx: Vec&lt;W&gt; = unsafe { std::mem::transmute(vx) };<\/code><\/pre>\n<p> <\/p>\n<h3>\u041f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0441 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430\u043c\u0438 \u0431\u0435\u0437 \u043f\u043e\u043b\u0435\u0439<\/h3>\n<p> \u041a\u043e\u0433\u0434\u0430 \u043c\u043d\u0435 \u043d\u0443\u0436\u043d\u044b \u0442\u0430\u043a\u0438\u0435 \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f, \u044f \u0434\u0443\u0431\u043b\u0438\u0440\u0443\u044e \u0438\u0445 \u0432 \u0434\u0432\u0443\u0445 \u043a\u0440\u0435\u0439\u0442\u0430\u0445 \u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>From<\/code> \u0432 \u0441\u0432\u043e\u0435\u043c \u043a\u0440\u0435\u0439\u0442\u0435 <code>*_py<\/code> \u0434\u043b\u044f \u043e\u0431\u043e\u0438\u0445 \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0439:<\/p>\n<pre><code class=\"python\">\/\/ in lib_rs  enum X {   A,   B, }  \/\/ in lib_py  enum X {   A,   B }  impl From&lt;rust::X&gt; for X { ... }  impl From&lt;X&gt; for rust::X { ... }<\/code><\/pre>\n<p> <\/p>\n<blockquote><p><i>\u0427\u0435\u0441\u0442\u043d\u043e \u0433\u043e\u0432\u043e\u0440\u044f, \u043e\u043d\u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u043d\u043e\u0441\u044f\u0442 \u043c\u043d\u0435 \u043a\u0440\u044b\u0448\u0443. \u0422\u0430\u043a\u0438\u0435 \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0432 \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u0441\u0442\u0435\u043f\u0435\u043d\u0438 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u044e\u0442\u0441\u044f PyO3, \u0438 \u044f \u043c\u043e\u0433\u0443 \u043f\u0440\u043e\u0441\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <code>#[pyclass]<\/code> \u0434\u043b\u044f \u043d\u0438\u0445, \u043d\u043e \u044d\u0442\u043e \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u043b\u0438\u0431\u043e \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u0430 \u0438\u0445 \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u043a\u0440\u0435\u0439\u0442 \u0441 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c\u044e \u043e\u0442 PyO3, \u043b\u0438\u0431\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 PyO3 \u0432 \u043c\u043e\u0439 \u043a\u0440\u0435\u0439\u0442 <code>*_rs<\/code>. \u041d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u044f \u0440\u0435\u0448\u0438\u043b \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c\u0441\u044f \u043d\u0430 \u0432\u044b\u0448\u0435\u043e\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u0438.<\/i><\/p><\/blockquote>\n<p> \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u043c\u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u0438\u0445 \u0432 \u043a\u0440\u0435\u0439\u0442 <code>enums<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c\u044e \u0434\u043b\u044f <code>lib_rs<\/code> \u0438 <code>lib_py<\/code>. \u042f \u0435\u0449\u0435 \u043d\u0435 \u0440\u0435\u0448\u0438\u043b.<\/p>\n<h3>\u041f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0435 \u0441 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430\u043c\u0438, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u043c\u0438 \u043f\u043e\u043b\u044f<\/h3>\n<p> \u0412 \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0435\u0435 \u0432\u0440\u0435\u043c\u044f \u043e\u043d\u0438 \u043d\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u0432 PyO3. \u042f \u0440\u0430\u0431\u043e\u0442\u0430\u044e \u0441 \u043d\u0438\u043c\u0438 \u0442\u0430\u043a, \u043a\u0430\u043a \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e \u043d\u0438\u0436\u0435:<\/p>\n<pre><code class=\"python\">use pyo3::prelude::*;  mod rust {     pub enum Pet {         Dog { name: String, age: u8 },         Hamster { name: String },     } }  #[pyclass] struct Pet(rust::Pet);  #[pyclass] struct Dog {     name: String,     age: u8, }  #[pyclass] struct Hamster {     name: String, }  #[pymethods] impl Pet {     fn is_dog(&amp;self) -&gt; bool {         matches!(&amp;self.0, Dog { name: _, age: _ })     }      fn is_hamster(&amp;self) -&gt; bool {         matches!(&amp;self.0, Hamster { name: _ })     }      fn as_dog(&amp;self) -&gt; Option&lt;Dog&gt; {         if let rust::Pet::Dog { name, age } = &amp;self.0 {             Some(Dog {                 name: name.clone(),                 age: *age,             })         }         None     }      fn as_hamster(&amp;self) -&gt; Option&lt;Hamster&gt; {         if let rust::Pet::Hamster { name } = &amp;self.0 {             Some(Hamster { name: name.clone() })         }         None     } }<\/code><\/pre>\n<p> <\/p>\n<h3>\u0420\u0430\u0431\u043e\u0442\u0430 \u0441 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f\u043c\u0438 \u0432 Python<\/h3>\n<p> \u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e PyO3 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043b\u0435\u0433\u043a\u043e \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u0442\u044c Rust Result (\u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u044f \u0442\u0430\u043a \u0438\u043b\u0438 \u0438\u043d\u0430\u0447\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e \u0435\u0433\u043e) \u0432 Python <code>PyResult<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0435 <code>Err<\/code> \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435\u043c Python:<\/p>\n<pre><code class=\"python\">use pyo3::exceptions::PyValueError; use pyo3::prelude::*;  mod rust {     use anyhow::Result;     pub fn u8_overflow_plus(add: u8, to: u8) -&gt; Result&lt;u8&gt; {         if add &gt; u8::MAX - to {             bail!(\"overflow\")         } else {             Ok(add + to)         }     } }  #[pyfunction] fn u8_overflow_plus(add: u8, to: u8) -&gt; PyResult&lt;u8&gt; {     rust::u8_overflow_plus(add, to)         .map_err(|e| PyValueError::new_err(format!(\"u8_overflow_plus: {}\", e))) }  \/\/ \u0443 \u0432\u0430\u0441 \u0432 py \/\/ try: \/\/     u8_overflow_plus(255, 255) \/\/ \u043a\u0440\u043e\u043c\u0435 ValueError: \/\/     # \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e<\/code><\/pre>\n<p> \u042f \u043e\u0447\u0435\u043d\u044c \u0447\u0430\u0441\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e <code>Result<\/code> \u0432 \u0441\u0432\u043e\u0435\u043c \u043a\u043e\u0434\u0435. \u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0438\u0434\u0435\u0430\u043b\u044c\u043d\u0430: \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u044c \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f Rust, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u043e \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u0442 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0432 Python. \u042f \u043d\u0430\u0445\u043e\u0436\u0443 \u044d\u0442\u043e \u0443\u0434\u0438\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c: \u0435\u0441\u043b\u0438 \u043e\u043d \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 <code>Ok(smth)<\/code>, \u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u043e\u0431\u044b\u0447\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 Python; \u0435\u0441\u043b\u0438 \u043e\u043d \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 <code>Err<\/code> \u2014 \u043a\u043e\u0434 Python \u043f\u043e\u0434\u043d\u0438\u043c\u0430\u0435\u0442 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435.<\/p>\n<h3>\u0420\u0430\u0431\u043e\u0442\u0430 \u0441 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430\u043c\u0438 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0434\u043b\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0438 \u043c\u0435\u0442\u043e\u0434\u043e\u0432<\/h3>\n<p> Python \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e, \u0438 \u044f \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0447\u0430\u0441\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e \u0438\u0445 \u0434\u043b\u044f \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u0438\u044f API. \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0432 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430\u0445, \u043c\u0435\u0442\u043e\u0434\u0430\u0445 \u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u0445.<\/p>\n<p> \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0432 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430\u0445:<\/p>\n<pre><code class=\"python\">#[pymethods] impl PersistentQueueWithCapacity {     #[new]     #[pyo3(signature=(path, max_elements = 1_000_000_000))]     fn new(path: &amp;str, max_elements: usize) -&gt; PyResult&lt;Self&gt; {     ... }<\/code><\/pre>\n<p> \u0412 \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u0445:<\/p>\n<pre><code class=\"python\">#[pyfunction] #[pyo3(signature=(x=0, i=1))] fn inc(x: i64, i: i64) -&gt; i64 { ... }  \/\/ \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0432\u044b\u0437\u0432\u0430\u043d\u043e \u0432 python \/\/ inc() \/\/ inc(1) \/\/ inc(i=10) \/\/ inc(x=1, i=10) \/\/ inc(1, 10)<\/code><\/pre>\n<p> \u0412 \u043c\u0435\u0442\u043e\u0434\u0430\u0445 (\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 self \u043d\u0443\u0436\u043d\u043e \u0438\u0433\u043d\u043e\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c):<\/p>\n<pre><code class=\"python\">#[pymethods] impl PersistentQueueWithCapacity {     #[pyo3(signature=(n = 1_000_000_000))]     fn set(&amp;mut self, n: usize) {     ... }<\/code><\/pre>\n<p> <\/p>\n<h3>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432<\/h3>\n<p> \u041e\u0431\u044b\u0447\u043d\u043e \u0432\u044b \u043f\u043e\u043c\u0435\u0447\u0430\u0435\u0442\u0435 \u043c\u0435\u0442\u043e\u0434 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u043c <code>#[new]<\/code>, \u0447\u0442\u043e\u0431\u044b \u0443\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e \u043e\u043d \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043a\u0430\u043a <code>__init__<\/code> \u0432 Python. \u041e\u0434\u043d\u0430\u043a\u043e \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439 \u044f \u043e\u0431\u044b\u0447\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e \u0434\u0440\u0443\u0433\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0432\u0441\u043f\u043e\u043c\u043d\u0438\u043c \u043d\u0430\u0448 \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0438\u0442\u0435\u043b\u044c <code>Pet<\/code> \u0438\u0437 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u0430:<\/p>\n<pre><code class=\"python\">use pyo3::prelude::*;  mod rust {     pub enum Pet {         Dog { name: String, age: u8 },         Hamster { name: String },     } }  #[pyclass] struct Pet(rust::Pet);  #[pyclass] struct Dog {     name: String,     age: u8, }  #[pyclass] struct Hamster {     name: String, }  #[pymethods] impl Pet {     #[staticmethod]     fn dog(name: String, age: u8) -&gt; Self {         Self(rust::Pet::Dog { name, age })     }     #[staticmethod]     fn hamster(name: String) -&gt; Self {         Self(rust::Pet::Hamster { name })     } }<\/code><\/pre>\n<p> \u0422\u0435\u043f\u0435\u0440\u044c, \u0432 Python, \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u044b \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code class=\"python\">dog = Pet.dog(\"Pike\", 3) hamster = Pet.hamster(\"Wheely\")<\/code><\/pre>\n<p> \u0412\u044b \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u043e\u0442 \u043f\u043e\u0434\u0445\u043e\u0434, \u0435\u0441\u043b\u0438 \u0432\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u043e\u0432 \u0434\u043b\u044f \u0432\u0430\u0448\u0435\u0439 \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u043e\u0439 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b, \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0446\u0435\u043b\u0438.<\/p>\n<h3>\u0420\u0430\u0431\u043e\u0442\u0430 \u0441 GIL <\/h3>\n<p> \u041e\u0441\u0432\u043e\u0431\u043e\u0436\u0434\u0435\u043d\u0438\u0435 GIL \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u0431\u044b\u0432\u0430\u0435\u0442 \u0443\u043c\u0435\u0441\u0442\u043d\u044b\u043c. \u041a\u043e\u0433\u0434\u0430 \u043a\u043e\u0434 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0431\u044b\u0441\u0442\u0440\u043e, \u044f \u043d\u0435 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u0443\u044e \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 GIL. \u042d\u043c\u043f\u0438\u0440\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u043f\u0443\u0442\u0435\u043c \u044f \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u043b, \u0447\u0442\u043e \u043a\u043e\u0434 \u043e\u0431\u044b\u0447\u043d\u043e \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u0435\u0435, \u043a\u043e\u0433\u0434\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0437\u0430\u0432\u0435\u0440\u0448\u0430\u0435\u0442\u0441\u044f \u0431\u044b\u0441\u0442\u0440\u0435\u0435, \u0447\u0435\u043c \u0437\u0430 <code>1000ns<\/code>, \u0438 \u044f \u043e\u0441\u0432\u043e\u0431\u043e\u0436\u0434\u0430\u044e GIL \u0432\u043d\u0443\u0442\u0440\u0438 \u043d\u0435\u0435. \u0418\u043d\u043e\u0433\u0434\u0430 \u044f \u043d\u0435 \u0443\u0432\u0435\u0440\u0435\u043d, \u043d\u0443\u0436\u043d\u043e \u043b\u0438 \u043e\u0441\u0432\u043e\u0431\u043e\u0436\u0434\u0430\u0442\u044c GIL \u0438\u043b\u0438 \u043d\u0435\u0442. \u0412 \u0442\u0430\u043a\u043e\u0439 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438 \u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0443\u044e \u0434\u0435\u043b\u0430\u0442\u044c \u0438 \u0442\u043e, \u0438 \u0434\u0440\u0443\u0433\u043e\u0435:<\/p>\n<pre><code class=\"python\">#[pyo3(signature = (items, no_gil = true))] fn push(&amp;mut self, items: Vec&lt;&amp;PyBytes&gt;, no_gil: bool) -&gt; PyResult&lt;()&gt; {     let data = items.iter().map(|e| e.as_bytes()).collect::&lt;Vec&lt;&amp;[u8]&gt;&gt;();     Python::with_gil(|py| {         let mut f = move || {             self.0                 .push(&amp;data)                 .map_err(|e| PyRuntimeError::new_err(format!(\"Failed to push item: {}\", e)))         };          if no_gil {             py.allow_threads(f)         } else {             f()         }     }) }<\/code><\/pre>\n<p> \u0421\u0442\u043e\u0440\u043e\u043d\u0430, \u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0449\u0430\u044f \u043a\u043e\u0434 \u043c\u043e\u0436\u0435\u0442 \u0440\u0435\u0448\u0438\u0442\u044c, \u043e\u0441\u0432\u043e\u0431\u043e\u0436\u0434\u0430\u0442\u044c \u0435\u0433\u043e \u0438\u043b\u0438 \u043d\u0435\u0442, \u043f\u0435\u0440\u0435\u0434\u0430\u0432 <code>no_gil=True \u0438\u043b\u0438 False<\/code>.<\/p>\n<p> \u041c\u043e\u0436\u043d\u043e \u0437\u0430\u0434\u0443\u043c\u0430\u0442\u044c\u0441\u044f, \u0430 \u0432 \u043a\u0430\u043a\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u043e\u0441\u0432\u043e\u0431\u043e\u0436\u0434\u0435\u043d\u0438\u0435 GIL \u043b\u0443\u0447\u0448\u0435 \u043d\u0435 \u0434\u0435\u043b\u0430\u0442\u044c. \u041f\u043e\u0437\u0432\u043e\u043b\u044c\u0442\u0435 \u043c\u043d\u0435 \u043e\u0431\u044a\u044f\u0441\u043d\u0438\u0442\u044c \u044d\u0442\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043f\u0441\u0435\u0432\u0434\u043e\u043a\u043e\u0434\u0430. \u041a\u043e\u0433\u0434\u0430 \u043c\u044b \u043d\u0435 \u043e\u0441\u0432\u043e\u0431\u043e\u0436\u0434\u0430\u0435\u043c GIL, \u0432\u0441\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code class=\"python\">ACQUIRE_GIL     &lt;&lt;&lt;&lt;&lt;   CALL function     DO STUFF   ENDCALL RELEASE_GIL<\/code><\/pre>\n<p> \u041a\u043e\u0433\u0434\u0430 \u043c\u044b \u043e\u0441\u0432\u043e\u0431\u043e\u0436\u0434\u0430\u0435\u043c GIL:<\/p>\n<pre><code class=\"python\">ACQUIRE_GIL     &lt;&lt;&lt;&lt;&lt;   CALL function     RELEASE_GIL       DO STUFF     ACQUIRE_GIL &lt;&lt;&lt;&lt;&lt;   ENDCALL RELEASE_GIL<\/code><\/pre>\n<p> \u0412\u044b \u0432\u0438\u0434\u0438\u0442\u0435, \u0447\u0442\u043e \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 <code>ACQUIRE GIL<\/code> \u0434\u0432\u0435, \u0430 \u043d\u0435 \u043e\u0434\u043d\u0430. \u041a\u0430\u0436\u0434\u0430\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f <code>ACQUIRE GIL<\/code> \u2014 \u044d\u0442\u043e \u0431\u043b\u043e\u043a\u0438\u0440\u0443\u044e\u0449\u0430\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f \u043f\u0440\u0438\u043e\u0431\u0440\u0435\u0442\u0435\u043d\u0438\u044f \u043c\u044c\u044e\u0442\u0435\u043a\u0441\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0436\u0434\u0435\u0442, \u043f\u043e\u043a\u0430 GIL \u043e\u0441\u0432\u043e\u0431\u043e\u0434\u0438\u0442\u0441\u044f. \u041f\u0440\u0438 \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u0438 \u0447\u0438\u0441\u043b\u0430 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0439 \u0440\u0430\u0431\u043e\u0442\u0430 \u0437\u0430\u043c\u0435\u0434\u043b\u044f\u0435\u0442\u0441\u044f.<\/p>\n<blockquote><p><i>\u041f\u0440\u043e\u0441\u0442\u043e \u043f\u043e\u043c\u043d\u0438\u0442\u0435, \u0447\u0442\u043e \u043a\u043e\u0433\u0434\u0430 \u0432\u0430\u0448 \u043a\u043e\u0434 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f, \u043e\u043d \u0443\u0436\u0435 \u0433\u043e\u0442\u043e\u0432 \u043a \u0440\u0430\u0431\u043e\u0442\u0435. \u042f \u043e\u0431\u044b\u0447\u043d\u043e \u0432\u044b\u043f\u0443\u0441\u043a\u0430\u044e GIL \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u043e\u0433\u0434\u0430, \u043a\u043e\u0433\u0434\u0430 \u043e\u043d \u043f\u043e\u0432\u044b\u0448\u0430\u0435\u0442 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043a\u043e\u043d\u043a\u0443\u0440\u0435\u043d\u0442\u043d\u043e\u0441\u0442\u0438.<\/i><\/p><\/blockquote>\n<p> <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/0-\/i_\/2c\/0-i_2cp79to3uyyht49l9dlaqrk.png\" sizes=\"(max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/webt\/0-\/i_\/2c\/0-i_2cp79to3uyyht49l9dlaqrk.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/webt\/0-\/i_\/2c\/0-i_2cp79to3uyyht49l9dlaqrk.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<p> \u0420\u0430\u043d\u044c\u0448\u0435, \u043a\u043e\u0433\u0434\u0430 \u044f \u0440\u0430\u0431\u043e\u0442\u0430\u043b \u0441 \u0434\u0432\u043e\u0438\u0447\u043d\u044b\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438, \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438 (\u0432 PyO3 \u043d\u0435\u043b\u044c\u0437\u044f \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/bn\/qa\/h3\/bnqah3ij17qtmavqfrasikskns4.png\" sizes=\"(max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/webt\/bn\/qa\/h3\/bnqah3ij17qtmavqfrasikskns4.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/webt\/bn\/qa\/h3\/bnqah3ij17qtmavqfrasikskns4.png 781w\" loading=\"lazy\" decode=\"async\"\/> \u0438\u043b\u0438 &amp;[u8]):<\/p>\n<pre><code class=\"python\">#[pyfunction] fn bypass_and_ret(v: Vec&lt;u8&gt;) -&gt; Vec&lt;u8&gt; {     v }<\/code><\/pre>\n<p> \u041e\u043d \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u044b\u0439, \u043a\u043e\u0433\u0434\u0430 \u0440\u0435\u0447\u044c \u0438\u0434\u0435\u0442 \u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0435 \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u0431\u0430\u0439\u0442\u043e\u0432\u044b\u0445 \u0431\u0443\u0444\u0435\u0440\u043e\u0432. \u041e\u043d \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u0435\u0442 \u0433\u0438\u0431\u043a\u043e\u0441\u0442\u044c: \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0431\u0430\u0439\u0442\u044b Python \u0438\u043b\u0438 <code>[1, 2, 3]<\/code>, \u043d\u043e \u044d\u0442\u043e \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u043e. \u0412 \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0435\u0435 \u0432\u0440\u0435\u043c\u044f \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u0431\u043e\u043b\u044c\u0448\u0438\u043c\u0438 \u0434\u0432\u043e\u0438\u0447\u043d\u044b\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u044f \u043f\u0440\u0435\u0434\u043f\u043e\u0447\u0438\u0442\u0430\u044e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <code>&amp;PyBytes<\/code> (\u0434\u0430, \u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0447\u0435\u0440\u0435\u0437 <code>&amp;<\/code>):<\/p>\n<pre><code class=\"python\">use pyo3::prelude::*; use pyo3::types::PyBytes;  #[pyfunction] fn bypass_and_ret(v: &amp;PyBytes) -&gt; PyObject {     let data = v.as_bytes();     Python::with_gil(|py| PyObject::from(PyBytes::new(py, data))) }<\/code><\/pre>\n<p> <\/p>\n<h3>\u0412\u0435\u0440\u0441\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438<\/h3>\n<p> \u041e\u0431\u044b\u0447\u043d\u043e \u044f \u043f\u043e\u043c\u0435\u0449\u0430\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>version()<\/code> \u0432 \u043f\u0430\u043a\u0435\u0442, \u0447\u0442\u043e\u0431\u044b \u043b\u0435\u0433\u043a\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c, \u0447\u0442\u043e \u0432\u0435\u0440\u0441\u0438\u044f \u0432\u0435\u0440\u043d\u0430 \u0438 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043e\u0436\u0438\u0434\u0430\u0435\u043c\u043e\u0439. \u041e\u0431\u044b\u0447\u043d\u043e \u044f \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u044e \u0432\u0435\u0440\u0441\u0438\u044e \u0432 \u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0449\u0435\u043c \u043a\u043e\u0434\u0435, \u0447\u0442\u043e\u0431\u044b \u0443\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u043a\u043e\u0434 \u043d\u0430 Python \u0438 Rust \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u044b.<\/p>\n<pre><code class=\"python\">mod rust {     pub fn version() -&gt; &amp;'static str { env!(\"CARGO_PKG_VERSION\") } }  #[pyfunction] fn version() -&gt; String { rust::version() }<\/code><\/pre>\n<p> <\/p>\n<h3>\u041f\u0430\u043a\u0435\u0442\u044b Python<\/h3>\n<p> \u0412 PyO3 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u044e\u0442 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0441 \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u043c\u0438 \u043f\u0430\u043a\u0435\u0442\u0430\u043c\u0438 Python. \u041f\u043e\u0433\u0443\u0433\u043b\u0438\u0432 \u0438 \u043f\u043e\u0447\u0438\u0442\u0430\u0432 \u043e\u0431\u0441\u0443\u0436\u0434\u0435\u043d\u0438\u044f, \u044f \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u043b, \u0447\u0442\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0438\u0434\u0435\u0430\u043b\u044c\u043d\u043e:<\/p>\n<pre><code class=\"python\">#[pymodule] fn rocksq_blocking(_: Python, m: &amp;PyModule) -&gt; PyResult&lt;()&gt; {     Ok(()) }  #[pymodule] fn rocksq_nonblocking(_: Python, m: &amp;PyModule) -&gt; PyResult&lt;()&gt; {     Ok(()) }  #[pymodule] fn rocksq(py: Python, m: &amp;PyModule) -&gt; PyResult&lt;()&gt; {     m.add_function(wrap_pyfunction!(version, m)?)?;      m.add_wrapped(wrap_pymodule!(rocksq_blocking))?;     m.add_wrapped(wrap_pymodule!(rocksq_nonblocking))?;      let sys = PyModule::import(py, \"sys\")?;     let sys_modules: &amp;PyDict = sys.getattr(\"modules\")?.downcast()?;      sys_modules.set_item(\"rocksq.blocking\", m.getattr(\"rocksq_blocking\")?)?;     sys_modules.set_item(\"rocksq.nonblocking\", m.getattr(\"rocksq_nonblocking\")?)?;      Ok(()) }<\/code><\/pre>\n<p> <\/p>\n<h3>\u041b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435<\/h3>\n<p> \u0412 PyO3 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u043f\u0430\u043a\u0435\u0442 (pyo3-log), \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0438\u0439 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0436\u0443\u0440\u043d\u0430\u043b\u044b Rust \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f Python (\u0438\u0437 <a href=\"https:\/\/pyo3.rs\/v0.19.2\/ecosystem\/logging\">\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438<\/a> PyO3):<\/p>\n<pre><code class=\"python\">use log::info; use pyo3::prelude::*;  #[pyfunction] fn log_something() {     \/\/ \u0417\u0434\u0435\u0441\u044c \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043b\u043e\u0433\u0433\u0435\u0440, \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u044b\u0439 \u0432 `my_module` \u2014 \u043e\u043d \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 `info`     \/\/ \u0432 \u043b\u043e\u0433\u0438\u0440\u0443\u044e\u0449\u0438\u0435 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u044b Python.     info!(\"Something!\"); }  #[pymodule] fn my_module(_py: Python&lt;'_&gt;, m: &amp;PyModule) -&gt; PyResult&lt;()&gt; {     \/\/ \u0418\u043c\u0435\u043d\u043d\u043e \u0437\u0434\u0435\u0441\u044c \u0443\u0434\u043e\u0431\u043d\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u043b\u043e\u0433\u0433\u0435\u0440, \u0434\u0435\u0439\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u0432 \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0438 Rust -&gt; Python      pyo3_log::init();      m.add_function(wrap_pyfunction!(log_something))?;     Ok(()) }<\/code><\/pre>\n<p> \u0412\u0441\u0435 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043f\u0440\u043e\u0441\u0442\u043e \u0437\u0430\u043c\u0435\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0434\u043e \u0442\u043e\u0433\u043e \u043c\u043e\u043c\u0435\u043d\u0442\u0430, \u043a\u043e\u0433\u0434\u0430 \u0432\u044b \u043f\u043e\u0439\u043c\u0435\u0442\u0435, \u0447\u0442\u043e \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c GIL \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437, \u043a\u043e\u0433\u0434\u0430 \u0432\u044b \u0447\u0442\u043e-\u0442\u043e \u043b\u043e\u0433\u0438\u0440\u0443\u0435\u0442\u0435.<\/p>\n<p> \u0412 \u0441\u0432\u043e\u0438\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445, \u043a\u043e\u0433\u0434\u0430 \u044d\u0442\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e, \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e \u043e\u0431\u0440\u0430\u0442\u043d\u0443\u044e \u0441\u0445\u0435\u043c\u0443: \u042f \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e Rust-\u043d\u0430\u0442\u0438\u0432\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0432 Python, \u0430 Python-\u043a\u043e\u0434 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0435\u0435 \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u0438\u043b\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u0432\u044b\u0432\u043e\u0434\u0430 \u043b\u043e\u0433\u043e\u0432 (log appender) \u0434\u043b\u044f \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u0441\u0432\u043e\u0438\u0445 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f Rust. \u041f\u0440\u0438\u043c\u0435\u0440 \u0442\u0430\u043a\u043e\u0433\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0430 \u043a \u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044e \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 <a href=\"https:\/\/github.com\/insight-platform\/savant-rs\/blob\/main\/savant_python\/src\/logging.rs\">\u0437\u0434\u0435\u0441\u044c<\/a>.<\/p>\n<h3>\u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0432 \u0432\u0438\u0434\u0435 \u043b\u0438\u0442\u0435\u0440\u0430\u043b\u043e\u0432<\/h3>\n<p> \u0427\u0442\u043e\u0431\u044b \u043f\u043e\u043c\u043e\u0447\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u043c \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f \u0432\u043e \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0435\u0439 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u0430, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0438\u043c \u043c\u0435\u0442\u043e\u0434\u044b <code>__repr__<\/code> \u0438 <code>__str__<\/code> dunder. \u0415\u0441\u043b\u0438 \u0432\u0430\u0448\u0430 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u043f\u0440\u0438\u0437\u043d\u0430\u043a <code>Debug<\/code>, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043f\u043e\u0434\u0445\u043e\u0434:<\/p>\n<pre><code class=\"python\">impl Struct {     fn __repr__(&amp;self) -&gt; String {         format!(\"{:?}\", &amp;self.0)     }      fn __str__(&amp;self) -&gt; String {         self.__repr__()     } }<\/code><\/pre>\n<p> \u041e\u043d\u0430 \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u043d\u0430 Python, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043d\u044f\u0442\u044c \u0438\u0445 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0438 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435.<\/p>\n<h3>\u0425\u0435\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u0430<\/h3>\n<p> \u0415\u0441\u043b\u0438 \u0432\u0430\u043c \u043d\u0443\u0436\u043d\u043e, \u0447\u0442\u043e\u0431\u044b \u0432\u0430\u0448 \u043e\u0431\u044a\u0435\u043a\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0441\u044f \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043a\u043b\u044e\u0447\u0430 \u0445\u044d\u0448\u0430, \u0432\u0430\u043c \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u044c\u0441\u044f \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c <code>__hash__<\/code> dunder:<\/p>\n<pre><code class=\"python\">impl Struct {     fn __hash__(&amp;self) -&gt; u64 {         let mut hasher = DefaultHasher::new();         self.hash(&amp;mut hasher);         hasher.finish()     } }<\/code><\/pre>\n<p> \u041a\u043e\u0433\u0434\u0430 \u044f \u0445\u043e\u0447\u0443 \u043f\u0440\u0435\u0434\u043e\u0442\u0432\u0440\u0430\u0442\u0438\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0434\u043b\u044f \u043a\u043b\u044e\u0447\u0435\u0439, \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e:<\/p>\n<pre><code class=\"python\">#[classattr] const __hash__: Option&lt;Py&lt;PyAny&gt;&gt; = None;<\/code><\/pre>\n<p> <\/p>\n<h3>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u0441 \u043c\u0430\u0441\u0441\u0438\u0432\u0430\u043c\u0438 \u043d\u0430\u0434 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u043c<\/h3>\n<p> \u042f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b \u044d\u0442\u0443 \u043c\u0435\u0445\u0430\u043d\u0438\u043a\u0443 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d \u0440\u0430\u0437 \u0432 \u0441\u0432\u043e\u0438\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445, \u043a\u043e\u0433\u0434\u0430 \u043e\u0431\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u043b \u0432\u0441\u0435 \u0432\u0435\u043a\u0442\u043e\u0440\u044b \u0432 \u043e\u0431\u044a\u0435\u043a\u0442. \u0412 \u043c\u043e\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0443 \u043c\u0435\u043d\u044f \u0431\u044b\u043b\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0430\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430:<\/p>\n<pre><code class=\"python\">#[pyclass] #[derive(Debug, Clone)] pub struct AttributeValuesView(Arc&lt;Vec&lt;rust::AttributeValue&gt;&gt;)<\/code><\/pre>\n<p> \u041c\u043e\u044f \u0446\u0435\u043b\u044c \u2014 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c API \u0434\u043b\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u043c <code>AttributeValue<\/code> \u0441 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u043e\u043c <code>[i]<\/code>. \u0427\u0442\u043e\u0431\u044b \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u043c, \u0432\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u0432\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 dunder (\u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u0447\u0442\u0435\u043d\u0438\u044f) \u0438\u043b\u0438 \u0442\u0440\u0438 (\u0434\u043b\u044f \u0447\u0442\u0435\u043d\u0438\u044f-\u0437\u0430\u043f\u0438\u0441\u0438):<\/p>\n<pre><code class=\"python\">#[pymethods] impl AttributeValuesView {     fn __getitem__(&amp;self, index: usize) -&gt; PyResult&lt;AttributeValue&gt; {         let v = self             .0             .get(index)             .ok_or(PyIndexError::new_err(\"index out of range\"))             .map(|x| x.clone())?;         Ok(AttributeValue(v))     }      fn __len__(&amp;self) -&gt; PyResult&lt;usize&gt; {         Ok(self.0.len())     } }<\/code><\/pre>\n<p> \u0415\u0441\u043b\u0438 \u0432\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0443 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430, \u0432\u0430\u043c \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f <code>__setitem__<\/code> dunder:<\/p>\n<pre><code class=\"python\">fn __setitem__(&amp;mut self, idx: isize, value: impl FromPyObject) -&gt; PyResult&lt;()&gt;<\/code><\/pre>\n<p> \u041e\u0442\u043b\u0438\u0447\u043d\u043e, \u0447\u0442\u043e \u0432 PyO3 \u0435\u0441\u0442\u044c <a href=\"https:\/\/pyo3.rs\/v0.14.5\/class\/protocols\">\u0440\u0430\u0437\u0434\u0435\u043b<\/a>, \u043f\u043e\u0441\u0432\u044f\u0449\u0435\u043d\u043d\u044b\u0439 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430\u043c \u043a\u043b\u0430\u0441\u0441\u043e\u0432, \u0433\u0434\u0435 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043d\u0430\u0439\u0442\u0438 \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438.<\/p>\n<h3>\u0414\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435<\/h3>\n<p> \u0414\u043e\u043b\u0433\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u043c\u043d\u0435 \u0431\u044b\u043b\u043e \u0442\u0440\u0443\u0434\u043d\u043e \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438 \u0432\u0438\u0434\u0435\u043b\u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u0435 \u0447\u0430\u0441\u0442\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b \u0438\u0437 Python, \u0431\u0435\u0437 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0438\u0437\u0443\u0447\u0430\u0442\u044c \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434 \u043d\u0430 Rust.<\/p>\n<p> \u041f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0435 \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u043e \u043f\u043e \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044e \u0442\u0430\u043a\u0438\u0445 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0439 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Sphinx \u0432\u044b \u043d\u0430\u0439\u0434\u0451\u0442\u0435 \u0432 \u043c\u043e\u0435\u0439 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0439 <a href=\"https:\/\/blog.savant-ai.io\/documenting-native-python-extensions-made-with-rust-and-pyo3-227aff68e481\">\u0441\u0442\u0430\u0442\u044c\u0435<\/a>. \u0417\u0434\u0435\u0441\u044c \u044f \u0435\u0433\u043e \u043d\u0435 \u043f\u0443\u0431\u043b\u0438\u043a\u0443\u044e, \u0447\u0442\u043e\u0431\u044b \u0441\u044d\u043a\u043e\u043d\u043e\u043c\u0438\u0442\u044c \u0432\u0430\u043c \u0432\u0440\u0435\u043c\u044f.<\/p>\n<h3>\u041f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u044f \u043a\u043e\u0434\u0430 \u043d\u0430 PYPI<\/h3>\n<p> \u0421 \u043d\u0430\u0442\u0438\u0432\u043d\u044b\u043c\u0438 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f\u043c\u0438 \u043d\u0435\u043b\u044c\u0437\u044f \u043f\u0440\u043e\u0441\u0442\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0438\u0445 \u0432 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u044e Python \u2014 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u0441\u043e\u0431\u0440\u0430\u043d\u043e \u0438 \u0441\u043b\u0438\u043d\u043a\u043e\u0432\u0430\u043d\u043e \u0441 \u043d\u0443\u0436\u043d\u044b\u043c\u0438 \u0432\u0435\u0440\u0441\u0438\u044f\u043c\u0438. \u0414\u043b\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u0438 \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0441\u0431\u043e\u0440\u043a\u0438 \u043d\u0430 \u0431\u0430\u0437\u0435 Docker \u0438 GitHub Actions.<\/p>\n<p> \u041f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0435 \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u043e \u043f\u043e \u0441\u0431\u043e\u0440\u043a\u0435 \u0442\u0430\u043a\u0438\u0445 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0439 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e GitHub Actions \u0432\u044b \u043d\u0430\u0439\u0434\u0451\u0442\u0435 \u0432 \u043c\u043e\u0435\u0439 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0439 <a href=\"https:\/\/blog.savant-ai.io\/building-portable-native-python-extensions-with-rust-pyo3-and-maturin-3c1a1634d324\">\u0441\u0442\u0430\u0442\u044c\u0435<\/a>. \u0417\u0434\u0435\u0441\u044c \u044f \u0435\u0433\u043e \u043d\u0435 \u043f\u0443\u0431\u043b\u0438\u043a\u0443\u044e, \u0447\u0442\u043e\u0431\u044b \u0441\u044d\u043a\u043e\u043d\u043e\u043c\u0438\u0442\u044c \u0432\u0430\u043c \u0432\u0440\u0435\u043c\u044f.<\/p>\n<h3>\u0414\u0435\u043c\u043e \u043f\u0440\u043e\u0435\u043a\u0442<\/h3>\n<p> \u042f \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u043b \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043f\u0440\u043e\u0435\u043a\u0442 <a href=\"https:\/\/github.com\/insight-platform\/RocksQ\">RocksQ<\/a> (\u043f\u0435\u0440\u0441\u0438\u0441\u0442\u0435\u043d\u0442\u043d\u0430\u044f \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 RocksDB), \u0433\u0434\u0435 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043d\u0430\u0439\u0442\u0438 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0439, \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0438 \u0441 \u0438\u0437\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u043c \u0437\u0434\u0435\u0441\u044c \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u043e\u043c.<\/p>\n<h3>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h3>\n<p> \u041d\u0430\u0434\u0435\u044e\u0441\u044c, \u044d\u0442\u043e \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u043e \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u0432\u0430\u043c \u043f\u0438\u0441\u0430\u0442\u044c \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f \u0434\u043b\u044f Python \u043d\u0430 Rust \u0441 \u043c\u0435\u043d\u044c\u0448\u0438\u043c\u0438 \u0442\u0440\u0443\u0434\u043d\u043e\u0441\u0442\u044f\u043c\u0438 \u0438 \u0431\u043e\u043b\u044c\u0448\u0435\u0439 \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u044c\u044e. \u0415\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u0435\u0441\u0442\u044c \u0441\u0432\u043e\u0438 \u0441\u043e\u0432\u0435\u0442\u044b, \u0438\u0434\u0435\u0438 \u043f\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044e \u0438\u043b\u0438 \u0437\u0430\u043c\u0435\u0447\u0430\u043d\u0438\u044f, \u0431\u0443\u0434\u0443 \u0440\u0430\u0434 \u0438\u0445 \u0443\u0441\u043b\u044b\u0448\u0430\u0442\u044c.<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/923438\/\"> https:\/\/habr.com\/ru\/articles\/923438\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-1\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\"><a href=\"https:\/\/habr.com\/ru\/companies\/piter\/articles\/923438\/\"><\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/oa\/t8\/sy\/oat8syxv3fulszrclawkrkdgbfq.png\" sizes=\"(max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/webt\/oa\/t8\/sy\/oat8syxv3fulszrclawkrkdgbfq.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/webt\/oa\/t8\/sy\/oat8syxv3fulszrclawkrkdgbfq.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/div>\n<p><\/a><br \/> \u0412\u044b, \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e, \u0443\u0436\u0435 \u0432\u0438\u0434\u0435\u043b\u0438 \u043d\u0435\u043c\u0430\u043b\u043e \u0441\u0442\u0430\u0442\u0435\u0439 \u0441 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0430\u043c\u0438 \u0432\u0440\u043e\u0434\u0435 \u00abPython, Rust \u2014 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c, \u0431\u043b\u0430-\u0431\u043b\u0430-\u0431\u043b\u0430\u2026\u00bb. \u041f\u0435\u0447\u0430\u043b\u044c\u043d\u043e, \u043d\u043e \u043f\u043e\u0447\u0442\u0438 \u0432\u0441\u0435 \u044d\u0442\u0438 \u0441\u0442\u0430\u0442\u044c\u0438 \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u0443\u044e\u0442 \u043b\u0438\u0448\u044c \u0441\u0430\u043c\u044b\u0435 \u043f\u0440\u043e\u0441\u0442\u044b\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u0443\u0440\u043e\u0432\u043d\u044f \u00abhello world\u00bb. \u0412 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 \u043d\u0438\u0445, \u0432 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u0445\u043e\u0447\u0443 \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0442\u0435\u043c, \u043a\u0430\u043a \u044f \u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u0443\u044e \u043a\u0440\u0443\u043f\u043d\u044b\u0435 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432 \u0438 \u043f\u043e\u0447\u0435\u043c\u0443 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u044e \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0442\u0435 \u0438\u043b\u0438 \u0438\u043d\u044b\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u044f.<\/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-465250","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/465250","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=465250"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/465250\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=465250"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=465250"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=465250"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}