44# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
55#
66# Translators:
7- # python-doc bot, 2025
87# Dmitry Luschan, 2025
8+ # python-doc bot, 2026
99#
1010#, fuzzy
1111msgid ""
1212msgstr ""
1313"Project-Id-Version : Python 3.14\n "
1414"Report-Msgid-Bugs-To : \n "
15- "POT-Creation-Date : 2025-12-19 14:15 +0000\n "
15+ "POT-Creation-Date : 2026-01-13 14:20 +0000\n "
1616"PO-Revision-Date : 2025-09-16 00:01+0000\n "
17- "Last-Translator : Dmitry Luschan, 2025 \n "
17+ "Last-Translator : python-doc bot, 2026 \n "
1818"Language-Team : Russian (https://app.transifex.com/python-doc/teams/5390/ru/)\n "
1919"MIME-Version : 1.0\n "
2020"Content-Type : text/plain; charset=UTF-8\n "
@@ -307,40 +307,90 @@ msgid ""
307307msgstr ""
308308
309309#: ../../library/heapq.rst:235
310- msgid "Priority Queue Implementation Notes "
310+ msgid "Other Applications "
311311msgstr ""
312312
313313#: ../../library/heapq.rst:237
314314msgid ""
315+ "`Medians <https://en.wikipedia.org/wiki/Median>`_ are a measure of central "
316+ "tendency for a set of numbers. In distributions skewed by outliers, the "
317+ "median provides a more stable estimate than an average (arithmetic mean). A"
318+ " running median is an `online algorithm "
319+ "<https://en.wikipedia.org/wiki/Online_algorithm>`_ that updates continuously"
320+ " as new data arrives."
321+ msgstr ""
322+
323+ #: ../../library/heapq.rst:244
324+ msgid ""
325+ "A running median can be efficiently implemented by balancing two heaps, a "
326+ "max-heap for values at or below the midpoint and a min-heap for values above"
327+ " the midpoint. When the two heaps have the same size, the new median is the"
328+ " average of the tops of the two heaps; otherwise, the median is at the top "
329+ "of the larger heap::"
330+ msgstr ""
331+
332+ #: ../../library/heapq.rst:250
333+ msgid ""
334+ "def running_median(iterable):\n"
335+ " \" Yields the cumulative median of values seen so far.\" \n"
336+ "\n"
337+ " lo = [] # max-heap\n"
338+ " hi = [] # min-heap (same size as or one smaller than lo)\n"
339+ "\n"
340+ " for x in iterable:\n"
341+ " if len(lo) == len(hi):\n"
342+ " heappush_max(lo, heappushpop(hi, x))\n"
343+ " yield lo[0]\n"
344+ " else:\n"
345+ " heappush(hi, heappushpop_max(lo, x))\n"
346+ " yield (lo[0] + hi[0]) / 2"
347+ msgstr ""
348+
349+ #: ../../library/heapq.rst:264
350+ msgid "For example::"
351+ msgstr ""
352+
353+ #: ../../library/heapq.rst:266
354+ msgid ""
355+ ">>> list(running_median([5.0, 9.0, 4.0, 12.0, 8.0, 9.0]))\n"
356+ "[5.0, 7.0, 5.0, 7.0, 8.0, 8.5]"
357+ msgstr ""
358+
359+ #: ../../library/heapq.rst:271
360+ msgid "Priority Queue Implementation Notes"
361+ msgstr ""
362+
363+ #: ../../library/heapq.rst:273
364+ msgid ""
315365"A `priority queue <https://en.wikipedia.org/wiki/Priority_queue>`_ is common"
316366" use for a heap, and it presents several implementation challenges:"
317367msgstr ""
318368
319- #: ../../library/heapq.rst:240
369+ #: ../../library/heapq.rst:276
320370msgid ""
321371"Sort stability: how do you get two tasks with equal priorities to be "
322372"returned in the order they were originally added?"
323373msgstr ""
324374
325- #: ../../library/heapq.rst:243
375+ #: ../../library/heapq.rst:279
326376msgid ""
327377"Tuple comparison breaks for (priority, task) pairs if the priorities are "
328378"equal and the tasks do not have a default comparison order."
329379msgstr ""
330380
331- #: ../../library/heapq.rst:246
381+ #: ../../library/heapq.rst:282
332382msgid ""
333383"If the priority of a task changes, how do you move it to a new position in "
334384"the heap?"
335385msgstr ""
336386
337- #: ../../library/heapq.rst:249
387+ #: ../../library/heapq.rst:285
338388msgid ""
339389"Or if a pending task needs to be deleted, how do you find it and remove it "
340390"from the queue?"
341391msgstr ""
342392
343- #: ../../library/heapq.rst:252
393+ #: ../../library/heapq.rst:288
344394msgid ""
345395"A solution to the first two challenges is to store entries as 3-element list"
346396" including the priority, an entry count, and the task. The entry count "
@@ -350,14 +400,14 @@ msgid ""
350400"tasks."
351401msgstr ""
352402
353- #: ../../library/heapq.rst:258
403+ #: ../../library/heapq.rst:294
354404msgid ""
355405"Another solution to the problem of non-comparable tasks is to create a "
356406"wrapper class that ignores the task item and only compares the priority "
357407"field::"
358408msgstr ""
359409
360- #: ../../library/heapq.rst:261
410+ #: ../../library/heapq.rst:297
361411msgid ""
362412"from dataclasses import dataclass, field\n"
363413"from typing import Any\n"
@@ -368,21 +418,21 @@ msgid ""
368418" item: Any=field(compare=False)"
369419msgstr ""
370420
371- #: ../../library/heapq.rst:269
421+ #: ../../library/heapq.rst:305
372422msgid ""
373423"The remaining challenges revolve around finding a pending task and making "
374424"changes to its priority or removing it entirely. Finding a task can be done"
375425" with a dictionary pointing to an entry in the queue."
376426msgstr ""
377427
378- #: ../../library/heapq.rst:273
428+ #: ../../library/heapq.rst:309
379429msgid ""
380430"Removing the entry or changing its priority is more difficult because it "
381431"would break the heap structure invariants. So, a possible solution is to "
382432"mark the entry as removed and add a new entry with the revised priority::"
383433msgstr ""
384434
385- #: ../../library/heapq.rst:277
435+ #: ../../library/heapq.rst:313
386436msgid ""
387437"pq = [] # list of entries arranged in a heap\n"
388438"entry_finder = {} # mapping of tasks to entries\n"
@@ -413,25 +463,25 @@ msgid ""
413463" raise KeyError('pop from an empty priority queue')"
414464msgstr ""
415465
416- #: ../../library/heapq.rst:307
466+ #: ../../library/heapq.rst:343
417467msgid "Theory"
418468msgstr ""
419469
420- #: ../../library/heapq.rst:309
470+ #: ../../library/heapq.rst:345
421471msgid ""
422472"Heaps are arrays for which ``a[k] <= a[2*k+1]`` and ``a[k] <= a[2*k+2]`` for"
423473" all *k*, counting elements from 0. For the sake of comparison, non-"
424474"existing elements are considered to be infinite. The interesting property "
425475"of a heap is that ``a[0]`` is always its smallest element."
426476msgstr ""
427477
428- #: ../../library/heapq.rst:314
478+ #: ../../library/heapq.rst:350
429479msgid ""
430480"The strange invariant above is meant to be an efficient memory "
431481"representation for a tournament. The numbers below are *k*, not ``a[k]``::"
432482msgstr ""
433483
434- #: ../../library/heapq.rst:317
484+ #: ../../library/heapq.rst:353
435485msgid ""
436486" 0\n"
437487"\n"
@@ -444,7 +494,7 @@ msgid ""
444494"15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30"
445495msgstr ""
446496
447- #: ../../library/heapq.rst:327
497+ #: ../../library/heapq.rst:363
448498msgid ""
449499"In the tree above, each cell *k* is topping ``2*k+1`` and ``2*k+2``. In a "
450500"usual binary tournament we see in sports, each cell is the winner over the "
@@ -457,7 +507,7 @@ msgid ""
457507"over the two topped cells."
458508msgstr ""
459509
460- #: ../../library/heapq.rst:336
510+ #: ../../library/heapq.rst:372
461511msgid ""
462512"If this heap invariant is protected at all time, index 0 is clearly the "
463513"overall winner. The simplest algorithmic way to remove it and find the "
@@ -468,7 +518,7 @@ msgid ""
468518"items, you get an *O*\\ (*n* log *n*) sort."
469519msgstr ""
470520
471- #: ../../library/heapq.rst:343
521+ #: ../../library/heapq.rst:379
472522msgid ""
473523"A nice feature of this sort is that you can efficiently insert new items "
474524"while the sort is going on, provided that the inserted items are not "
@@ -480,7 +530,7 @@ msgid ""
480530"implementing schedulers (this is what I used for my MIDI sequencer :-)."
481531msgstr ""
482532
483- #: ../../library/heapq.rst:352
533+ #: ../../library/heapq.rst:388
484534msgid ""
485535"Various structures for implementing schedulers have been extensively "
486536"studied, and heaps are good for this, as they are reasonably speedy, the "
@@ -489,7 +539,7 @@ msgid ""
489539"efficient overall, yet the worst cases might be terrible."
490540msgstr ""
491541
492- #: ../../library/heapq.rst:358
542+ #: ../../library/heapq.rst:394
493543msgid ""
494544"Heaps are also very useful in big disk sorts. You most probably all know "
495545"that a big sort implies producing \" runs\" (which are pre-sorted sequences, "
@@ -503,7 +553,7 @@ msgid ""
503553" input fuzzily ordered."
504554msgstr ""
505555
506- #: ../../library/heapq.rst:368
556+ #: ../../library/heapq.rst:404
507557msgid ""
508558"Moreover, if you output the 0'th item on disk and get an input which may not"
509559" fit in the current tournament (because the value \" wins\" over the last "
@@ -514,17 +564,17 @@ msgid ""
514564"start a new run. Clever and quite effective!"
515565msgstr ""
516566
517- #: ../../library/heapq.rst:376
567+ #: ../../library/heapq.rst:412
518568msgid ""
519569"In a word, heaps are useful memory structures to know. I use them in a few "
520570"applications, and I think it is good to keep a 'heap' module around. :-)"
521571msgstr ""
522572
523- #: ../../library/heapq.rst:380
573+ #: ../../library/heapq.rst:416
524574msgid "Footnotes"
525575msgstr "Примечания"
526576
527- #: ../../library/heapq.rst:381
577+ #: ../../library/heapq.rst:417
528578msgid ""
529579"The disk balancing algorithms which are current, nowadays, are more annoying"
530580" than clever, and this is a consequence of the seeking capabilities of the "
0 commit comments