{"id":288021,"date":"2018-08-16T14:21:16","date_gmt":"2018-08-16T10:21:16","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=288021"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=288021","title":{"rendered":"\u0421\u043a\u043e\u043b\u044c\u043a\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0432\u044b\u0434\u0435\u043b\u044f\u0435\u0442 Python, \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044f \u0441\u043a\u0440\u0438\u043f\u0442\u044b?"},"content":{"rendered":"\n<div data-io-article-url=\"https:\/\/habr.com\/post\/418305\/\" class=\"post__text post__text-html js-mediator-article\">\u041d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 Python \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u044b \u0441\u0438\u043b\u044c\u043d\u043e \u0443\u0434\u0438\u0432\u043b\u044f\u044e\u0442\u0441\u044f, \u043a\u043e\u0433\u0434\u0430 \u0443\u0437\u043d\u0430\u044e\u0442 \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0442\u043e\u0440 \u043f\u0438\u0442\u043e\u043d\u0430 \u0432\u044b\u0434\u0435\u043b\u044f\u0435\u0442 \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e \u0441\u043a\u0440\u0438\u043f\u0442\u0430. <\/p>\n<p>  CPython \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0443 \u043f\u043e \u0432\u044b\u0434\u0435\u043b\u044f\u0435\u043c\u044b\u043c \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c, \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0435\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c\u0438 \u0444\u043b\u0430\u0433\u0430\u043c\u0438.<\/p>\n<pre><code class=\"bash\">.\/configure CFLAGS='-DCOUNT_ALLOCS' --with-pydebug  make -s -j2 <\/code><\/pre>\n<p><a name=\"habracut\"><\/a><br \/>  \u041f\u043e\u0441\u043b\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043e\u0442\u043a\u0440\u044b\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0439 REPL \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0443:<\/p>\n<pre><code class=\"python\">&gt;&gt;&gt; import sys &gt;&gt;&gt; sys.getcounts() [('iterator', 7, 7, 4), ('functools._lru_cache_wrapper', 1, 0, 1), ('re.Match', 2, 2, 1), ('re.Pattern', 3, 2, 1), ('SubPattern', 10, 10, 8), ('Pattern', 3, 3, 1), ('IndexError', 4, 4, 1), ('Tokenizer', 3, 3, 1), ('odict_keys', 1, 1, 1), ('odict_iterator', 18, 18, 1), ('odict_items', 17, 17, 1), ('RegexFlag', 18, 8, 10), ('operator.itemgetter', 4, 0, 4), ('PyCapsule', 1, 1, 1), ('Repr', 1, 0, 1), ('_NamedIntConstant', 74, 0, 74), ('collections.OrderedDict', 5, 0, 5), ('EnumMeta', 5, 0, 5), ('DynamicClassAttribute', 2, 0, 2), ('_EnumDict', 5, 5, 1), ('TypeError', 1, 1, 1), ('method-wrapper', 365, 365, 2), ('_C', 1, 1, 1), ('symtable entry', 5, 5, 2), ('OSError', 1, 1, 1), ('Completer', 1, 0, 1), ('ExtensionFileLoader', 2, 0, 2), ('ModuleNotFoundError', 2, 2, 1), ('_Helper', 1, 0, 1), ('_Printer', 3, 0, 3), ('Quitter', 2, 0, 2), ('enumerate', 5, 5, 1), ('_io.IncrementalNewlineDecoder', 1, 1, 1), ('map', 25, 25, 1), ('_Environ', 2, 0, 2), ('async_generator', 2, 1, 1), ('coroutine', 2, 2, 1), ('zip', 1, 1, 1), ('longrange_iterator', 1, 1, 1), ('range_iterator', 7, 7, 1), ('range', 14, 14, 2), ('list_reverseiterator', 2, 2, 1), ('dict_valueiterator', 1, 1, 1), ('dict_values', 2, 2, 1), ('dict_keyiterator', 25, 25, 1), ('dict_keys', 5, 5, 1), ('bytearray_iterator', 1, 1, 1), ('bytearray', 4, 4, 1), ('bytes_iterator', 2, 2, 1), ('IncrementalEncoder', 2, 0, 2), ('_io.BufferedWriter', 2, 0, 2), ('IncrementalDecoder', 2, 1, 2), ('_io.TextIOWrapper', 4, 1, 4), ('_io.BufferedReader', 2, 1, 2), ('_abc_data', 39, 0, 39), ('mappingproxy', 199, 199, 1), ('ABCMeta', 39, 0, 39), ('CodecInfo', 1, 0, 1), ('str_iterator', 7, 7, 1), ('memoryview', 60, 60, 2), ('managedbuffer', 31, 31, 1), ('slice', 589, 589, 1), ('_io.FileIO', 33, 30, 5), ('SourceFileLoader', 29, 0, 29), ('set', 166, 101, 80), ('StopIteration', 33, 33, 1), ('FileFinder', 11, 0, 11), ('os.stat_result', 145, 145, 1), ('ImportError', 2, 2, 1), ('FileNotFoundError', 10, 10, 1), ('ZipImportError', 12, 12, 1), ('zipimport.zipimporter', 12, 12, 1), ('NameError', 4, 4, 1), ('set_iterator', 46, 46, 1), ('frozenset', 50, 0, 50), ('_ImportLockContext', 113, 113, 1), ('list_iterator', 305, 305, 5), ('_thread.lock', 92, 92, 10), ('_ModuleLock', 46, 46, 5), ('KeyError', 67, 67, 2), ('_ModuleLockManager', 46, 46, 5), ('generator', 125, 125, 1), ('_installed_safely', 52, 52, 5), ('method', 1095, 1093, 14), ('ModuleSpec', 58, 4, 54), ('AttributeError', 22, 22, 1), ('traceback', 154, 154, 3), ('dict_itemiterator', 45, 45, 1), ('dict_items', 46, 46, 1), ('object', 8, 1, 7), ('tuple_iterator', 631, 631, 3), ('cell', 71, 31, 42), ('classmethod', 58, 0, 58), ('property', 18, 2, 16), ('super', 360, 360, 1), ('type', 78, 3, 75), ('function', 1705, 785, 922), ('frame', 5442, 5440, 36), ('code', 1280, 276, 1063), ('bytes', 2999, 965, 2154), ('Token.MISSING', 1, 0, 1), ('stderrprinter', 1, 1, 1), ('MemoryError', 16, 16, 16), ('sys.thread_info', 1, 0, 1), ('sys.flags', 2, 0, 2), ('types.SimpleNamespace', 1, 0, 1), ('sys.version_info', 1, 0, 1), ('sys.hash_info', 1, 0, 1), ('sys.int_info', 1, 0, 1), ('float', 584, 569, 20), ('sys.float_info', 1, 0, 1), ('module', 56, 0, 56), ('staticmethod', 16, 0, 16), ('weakref', 505, 82, 426), ('int', 3540, 2775, 766), ('member_descriptor', 246, 10, 239), ('list', 992, 919, 85), ('getset_descriptor', 240, 4, 240), ('classmethod_descriptor', 12, 0, 12), ('method_descriptor', 678, 0, 678), ('builtin_function_or_method', 1796, 1151, 651), ('wrapper_descriptor', 1031, 5, 1026), ('str', 16156, 9272, 6950), ('dict', 1696, 900, 810), ('tuple', 10367, 6110, 4337)] <\/code><\/pre>\n<p>  \u0421\u0434\u0435\u043b\u0430\u0435\u043c \u0432\u044b\u0432\u043e\u0434 \u0431\u043e\u043b\u0435\u0435 \u0447\u0438\u0442\u0430\u0431\u0435\u043b\u044c\u043d\u044b\u043c:<\/p>\n<pre><code class=\"python\">def print_allocations(top_k=None):     allocs = sys.getcounts()     if top_k:         allocs = sorted(allocs, key=lambda tup: tup[1], reverse=True)[0:top_k]      for obj in allocs:         alive = obj[1]-obj[2]         print(\"Type {},  allocs: {}, deallocs: {}, max: {}, alive: {}\".format(*obj,alive)) <\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"python\">&gt;&gt;&gt; print_allocations(10) Type str,  allocs: 17328, deallocs: 10312, max: 7016, alive: 7016 Type tuple,  allocs: 10550, deallocs: 6161, max: 4389, alive: 4389 Type frame,  allocs: 5445, deallocs: 5442, max: 36, alive: 3 Type int,  allocs: 3988, deallocs: 3175, max: 813, alive: 813 Type bytes,  allocs: 3031, deallocs: 1044, max: 2154, alive: 1987 Type builtin_function_or_method,  allocs: 1809, deallocs: 1164, max: 651, alive: 645 Type dict,  allocs: 1726, deallocs: 930, max: 815, alive: 796 Type function,  allocs: 1706, deallocs: 811, max: 922, alive: 895 Type code,  allocs: 1284, deallocs: 304, max: 1063, alive: 980 Type method,  allocs: 1095, deallocs: 1093, max: 14, alive: 2 <\/code><\/pre>\n<p>  \u0413\u0434\u0435:<\/p>\n<ul>\n<li>allocs \u2014 \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0431\u044b\u043b\u043e \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u043e \u0441 \u043c\u043e\u043c\u0435\u043d\u0442\u0430 \u0441\u0442\u0430\u0440\u0442\u0430 \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0442\u043e\u0440\u0430 <\/li>\n<li>deallocs \u2014 \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0431\u044b\u043b\u043e \u0443\u0434\u0430\u043b\u0435\u043d\u043e (\u0432\u0440\u0443\u0447\u043d\u0443\u044e \u0438\u043b\u0438 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438)<\/li>\n<li>alive \u2014 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0436\u0438\u0432\u044b\u0445 (\u0442\u0435\u043a\u0443\u0449\u0438\u0445) \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 (allocs \u2014 deallocs)<\/li>\n<li>max \u2014 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0436\u0438\u0432\u044b\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0441 \u043c\u043e\u043c\u0435\u043d\u0442\u0430 \u0441\u0442\u0430\u0440\u0442\u0430 \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0442\u043e\u0440\u0430<\/li>\n<\/ul>\n<p>  \u041a\u0430\u043a \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0432\u0438\u0434\u0435\u0442\u044c, \u043f\u0443\u0441\u0442\u043e\u0439 Python REPL \u0443\u0441\u043f\u0435\u043b \u0432\u044b\u0434\u0435\u043b\u0438\u0442\u044c <b>17 328<\/b> \u0441\u0442\u0440\u043e\u043a and <b>10 550 <\/b>\u043a\u043e\u0440\u0442\u0435\u0436\u0435\u0439. \u042d\u0442\u043e \u043a\u0430\u043a\u043e\u0435-\u0442\u043e \u0431\u0435\u0437\u0443\u043c\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432! \u0417\u0434\u0435\u0441\u044c \u043d\u0443\u0436\u043d\u043e \u0438\u043c\u0435\u0442\u044c \u0432 \u0432\u0438\u0434\u0443, \u0447\u0442\u043e \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b REPL, Python \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u0442 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043c\u043e\u0434\u0443\u043b\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435 \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0441 \u043f\u0443\u0441\u0442\u044b\u043c\u0438 \u0441\u043a\u0440\u0438\u043f\u0442\u0430\u043c\u0438. <\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u0440\u043e\u0442\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u043c \u00abHello, World\u00bb \u043d\u0430 flask:<\/p>\n<pre><code class=\"python\">import sys  from flask import Flask app = Flask(__name__)  @app.route('\/') def hello_world():     print_allocations(15)     return 'Hello, World!' <\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"bash\">.\/python -m flask run ab -n 100 http:\/\/127.0.0.1:5000\/ <\/code><\/pre>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 100 HTTP \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043d\u0430 \u043d\u0430\u0448 \u0441\u0435\u0440\u0432\u0435\u0440 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0430 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<\/p>\n<pre><code class=\"bash\">Type str,  allocs: 192649, deallocs: 138892, max: 54320, alive: 53757 Type frame,  allocs: 191752, deallocs: 191714, max: 158, alive: 38 Type tuple,  allocs: 183474, deallocs: 150069, max: 33581, alive: 33405 Type int,  allocs: 85154, deallocs: 81100, max: 4115, alive: 4054 Type bytes,  allocs: 31671, deallocs: 14331, max: 17381, alive: 17340 Type list,  allocs: 29846, deallocs: 27541, max: 2415, alive: 2305 Type builtin_function_or_method,  allocs: 28525, deallocs: 27572, max: 957, alive: 953 Type dict,  allocs: 19900, deallocs: 14800, max: 5280, alive: 5100 Type method,  allocs: 15170, deallocs: 15105, max: 74, alive: 65 Type function,  allocs: 14761, deallocs: 7086, max: 7711, alive: 7675 Type slice,  allocs: 12521, deallocs: 12521, max: 1, alive: 0 Type list_iterator,  allocs: 10795, deallocs: 10795, max: 35, alive: 0 Type code,  allocs: 9849, deallocs: 1749, max: 8107, alive: 8100 Type tuple_iterator,  allocs: 8938, deallocs: 8938, max: 4, alive: 0 Type float,  allocs: 6033, deallocs: 5889, max: 152, alive: 144 <\/code><\/pre>\n<p>  \u041a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0432\u0438\u0434\u0435\u0442\u044c, flask \u0432\u044b\u0434\u0435\u043b\u0438\u043b <b>847 261<\/b> \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0441 \u043c\u043e\u043c\u0435\u043d\u0442\u0430 \u0441\u0442\u0430\u0440\u0442\u0430 \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0442\u043e\u0440\u0430. \u0411\u043e\u043b\u044c\u0448\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u0438\u0437 \u043d\u0438\u0445 \u0431\u044b\u043b\u0430 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 (<b>714 336<\/b>) \u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u0430 \u043a\u0430\u043a \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u043d\u0438 \u0431\u043e\u043b\u044c\u0448\u0435 \u0431\u044b\u043b\u0438 \u043d\u0435 \u043d\u0443\u0436\u043d\u044b. \u041e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b (<b>132 925<\/b>) \u043f\u043e \u043f\u0440\u0435\u0436\u043d\u0435\u043c\u0443 \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u0432 \u043f\u0430\u043c\u044f\u0442\u0438. <\/p>\n<h4>\u0424\u0440\u0435\u0439\u043c\u044b \u0438 code \u043e\u0431\u044a\u0435\u043a\u0442\u044b<\/h4>\n<p>  \u0412 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0432\u044b\u0448\u0435 \u043c\u043e\u0436\u043d\u043e \u0432\u0441\u0442\u0440\u0435\u0442\u0438\u0442\u044c \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e frame \u0438 code \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432. \u0417\u0430\u0447\u0435\u043c \u043e\u043d\u0438 \u043d\u0443\u0436\u043d\u044b?<\/p>\n<p>  \u0415\u0441\u043b\u0438 \u043a\u043e\u0440\u043e\u0442\u043a\u043e, \u0442\u043e \u043a\u0430\u0436\u0434\u044b\u0439 code \u043e\u0431\u044a\u0435\u043a\u0442 \u0445\u0440\u0430\u043d\u0438\u0442 \u0432 \u0441\u0435\u0431\u0435 \u0431\u043b\u043e\u043a \u0438\u0437 \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430, \u0432 \u0441\u0432\u043e\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c frame \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0434\u043b\u044f \u0438\u0445 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f, \u0440\u0430\u0431\u043e\u0442\u0430\u044f \u043f\u043e \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0443 <a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%A1%D1%82%D0%B5%D0%BA_%D0%B2%D1%8B%D0%B7%D0%BE%D0%B2%D0%BE%D0%B2\">\u0441\u0442\u044d\u043a\u0430 \u0432\u044b\u0437\u043e\u0432\u043e\u0432<\/a>. \u0412 Python, \u0441\u0430\u043c\u044b\u0439 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0439 \u0431\u043b\u043e\u043a \u2014 \u0444\u0443\u043d\u043a\u0446\u0438\u044f. \u0414\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u043d\u043e\u0432\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043d\u0443\u0436\u0435\u043d \u0441\u0432\u043e\u0439 code \u043e\u0431\u044a\u0435\u043a\u0442, \u0430 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0432\u044b\u0437\u043e\u0432\u0430 \u044d\u0442\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043d\u0443\u0436\u0435\u043d \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 frame \u043e\u0431\u044a\u0435\u043a\u0442, \u0433\u0434\u0435 Python \u0431\u0443\u0434\u0435\u0442 \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435. \u041f\u043e\u043c\u0438\u043c\u043e \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0445 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445, \u043a\u0430\u0436\u0434\u044b\u0439 frame \u043e\u0431\u044a\u0435\u043a\u0442 \u0445\u0440\u0430\u043d\u0438\u0442 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0443\u0436\u043d\u044b \u0434\u043b\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438. <\/p>\n<h4>\u041e\u0442\u043a\u0443\u0434\u0430 \u0431\u0435\u0440\u0443\u0442\u0441\u044f \u0432\u0441\u0435 \u044d\u0442\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u044b?<\/h4>\n<p>  Python \u043e\u0447\u0435\u043d\u044c \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u044f\u0437\u044b\u043a \u0438 \u0437\u0430 \u044d\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u043f\u043b\u0430\u0442\u0438\u0442\u044c. \u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0442\u044c \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438, \u043e\u043d \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442 \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u0440\u043e\u043b\u044c.<\/p>\n<p>  \u0414\u043b\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u0430, \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u043f\u043e \u043c\u0435\u043d\u044c\u0448\u0435\u0439 \u043c\u0435\u0440\u0435 5 \u0441\u043b\u043e\u0432\u0430\u0440\u0435\u0439, 5 \u043a\u043e\u0440\u0442\u0435\u0436\u0435\u0439 \u0438 4 \u0441\u043f\u0438\u0441\u043a\u0430. \u042d\u0442\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0431\u0443\u0434\u0443\u0442 \u0436\u0438\u0442\u044c \u0434\u043e \u043a\u043e\u043d\u0446\u0430 \u0440\u0430\u0431\u043e\u0442\u044b \u0441\u043a\u0440\u0438\u043f\u0442\u0430. \u0412 \u0441\u0432\u043e\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c, \u0432\u0441\u0435 \u044d\u0442\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0445\u0440\u0430\u043d\u044f\u0442 \u0432 \u0441\u0435\u0431\u0435 \u0434\u0440\u0443\u0433\u0438\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b (\u0438\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b), \u044d\u0442\u043e \u0434\u0435\u0441\u044f\u0442\u043a\u0438, \u0438\u043d\u043e\u0433\u0434\u0430 \u0441\u043e\u0442\u043d\u0438 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u043c\u044b\u0445 \u0434\u043b\u044f \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0435\u0433\u043e \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438. \u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0441\u0440\u0435\u0434\u043d\u0435\u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u0434\u0435\u043b\u0438\u0442\u044c \u0441\u043e\u0442\u043d\u0438 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u043d\u044b\u0445 (\u0441\u043b\u043e\u0432\u0430\u0440\u0435\u0439, \u043a\u043e\u0440\u0442\u0435\u0436\u0435\u0439, \u0441\u043f\u0438\u0441\u043a\u043e\u0432) \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432. \u041a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, \u0437\u0434\u0435\u0441\u044c \u0443\u0436\u0435 \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u043e\u0434\u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0442\u043e\u0447\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0432\u044b\u0434\u0435\u043b\u044f\u0435\u043c\u044b\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0438 \u044d\u0442\u0438 \u0446\u0438\u0444\u0440\u044b \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u044b\u043c\u0438. <\/p>\n<p>  \u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b Python \u0431\u044b\u0441\u0442\u0440\u043e \u0432\u044b\u0434\u0435\u043b\u044f\u043b \u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432, \u0432 \u043d\u0451\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f <a href=\"https:\/\/rushter.com\/blog\/python-memory-managment\/\">\u0431\u043e\u043b\u044c\u0448\u0430\u044f \u0438 \u043c\u043d\u043e\u0433\u043e\u0441\u043b\u043e\u0439\u043d\u0430\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u0430,<\/a> \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u0443\u0435\u0442 \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0432 \u043f\u0430\u043c\u044f\u0442\u0438. <\/p>\n<p>  \u0418\u043d\u043e\u0433\u0434\u0430 \u0443\u0434\u0438\u0432\u043b\u044f\u0435\u0448\u044c\u0441\u044f, \u043a\u0430\u043a \u043c\u043d\u043e\u0433\u043e \u0434\u0435\u0442\u0430\u043b\u0435\u0439 \u0441\u043a\u0440\u044b\u0432\u0430\u044e\u0442 \u043e\u0442 \u043d\u0430\u0441 \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0438\u0440\u0443\u0435\u043c\u044b\u0435 \u044f\u0437\u044b\u043a\u0438. Python \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u0438\u0441\u0430\u0442\u044c \u0445\u043e\u0440\u043e\u0448\u0438\u0439 \u043a\u043e\u0434 \u043d\u0435 \u0434\u0443\u043c\u0430\u044f \u043e \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u0438 \u0434\u0435\u0442\u0430\u043b\u0435\u0439. <\/p>\n<p>  P.S.: \u042f \u044f\u0432\u043b\u044f\u044e\u0441\u044c \u0430\u0432\u0442\u043e\u0440\u043e\u043c \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438, \u043c\u043e\u0436\u0435\u0442\u0435 \u0437\u0430\u0434\u0430\u0432\u0430\u0442\u044c \u043b\u044e\u0431\u044b\u0435 \u0432\u043e\u043f\u0440\u043e\u0441\u044b.<\/p><\/div>\n<p>        <script class=\"js-mediator-script\">!function(e){function t(t,n){if(!(n in e)){for(var r,a=e.document,i=a.scripts,o=i.length;o--;)if(-1!==i[o].src.indexOf(t)){r=i[o];break}if(!r){r=a.createElement(\"script\"),r.type=\"text\/javascript\",r.async=!0,r.defer=!0,r.src=t,r.charset=\"UTF-8\";var d=function(){var e=a.getElementsByTagName(\"script\")[0];e.parentNode.insertBefore(r,e)};\"[object Opera]\"==e.opera?a.addEventListener?a.addEventListener(\"DOMContentLoaded\",d,!1):e.attachEvent(\"onload\",d):d()}}}t(\"\/\/mediator.mail.ru\/script\/2820404\/\",\"_mediator\")}(window);<\/script>     <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\/post\/418305\/\"> https:\/\/habr.com\/post\/418305\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div data-io-article-url=\"https:\/\/habr.com\/post\/418305\/\" class=\"post__text post__text-html js-mediator-article\">\u041d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 Python \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u044b \u0441\u0438\u043b\u044c\u043d\u043e \u0443\u0434\u0438\u0432\u043b\u044f\u044e\u0442\u0441\u044f, \u043a\u043e\u0433\u0434\u0430 \u0443\u0437\u043d\u0430\u044e\u0442 \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0442\u043e\u0440 \u043f\u0438\u0442\u043e\u043d\u0430 \u0432\u044b\u0434\u0435\u043b\u044f\u0435\u0442 \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e \u0441\u043a\u0440\u0438\u043f\u0442\u0430. <\/p>\n<p>  CPython \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0443 \u043f\u043e \u0432\u044b\u0434\u0435\u043b\u044f\u0435\u043c\u044b\u043c \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c, \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0435\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c\u0438 \u0444\u043b\u0430\u0433\u0430\u043c\u0438.<\/p>\n<pre><code class=\"bash\">.\/configure CFLAGS='-DCOUNT_ALLOCS' --with-pydebug  make -s -j2 <\/code><\/pre>\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-288021","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/288021","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=288021"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/288021\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=288021"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=288021"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=288021"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}