From c257617e3bd7647e75471fef29d0f73156c86fdd Mon Sep 17 00:00:00 2001 From: Jos Verlinde Date: Thu, 13 Nov 2025 01:20:18 +0100 Subject: [PATCH 1/5] aioble\examples\temp_sensor: Change name to _ADV_INTERVAL_US. closes: https://github.com/micropython/micropython-lib/issues/1055 Signed-off-by: Jos Verlinde --- micropython/bluetooth/aioble/examples/temp_sensor.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/micropython/bluetooth/aioble/examples/temp_sensor.py b/micropython/bluetooth/aioble/examples/temp_sensor.py index 54580f595..9a4ec26de 100644 --- a/micropython/bluetooth/aioble/examples/temp_sensor.py +++ b/micropython/bluetooth/aioble/examples/temp_sensor.py @@ -20,7 +20,7 @@ _ADV_APPEARANCE_GENERIC_THERMOMETER = const(768) # How frequently to send advertising beacons. -_ADV_INTERVAL_MS = 250_000 +_ADV_INTERVAL_US = 250_000 # Register GATT server. @@ -50,7 +50,7 @@ async def sensor_task(): async def peripheral_task(): while True: async with await aioble.advertise( - _ADV_INTERVAL_MS, + _ADV_INTERVAL_US, name="mpy-temp", services=[_ENV_SENSE_UUID], appearance=_ADV_APPEARANCE_GENERIC_THERMOMETER, From 6b7bc907d1dc108fbca0855152ed6aa75820ff5e Mon Sep 17 00:00:00 2001 From: Jos Verlinde Date: Thu, 13 Nov 2025 01:45:23 +0100 Subject: [PATCH 2/5] aioble/README: Fix typo in aioble.ADDR_PUBLIC. closes: https://github.com/micropython/micropython-lib/issues/699 Signed-off-by: Jos Verlinde --- micropython/bluetooth/aioble/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/micropython/bluetooth/aioble/README.md b/micropython/bluetooth/aioble/README.md index 83ae00209..559594850 100644 --- a/micropython/bluetooth/aioble/README.md +++ b/micropython/bluetooth/aioble/README.md @@ -93,7 +93,7 @@ async with aioble.scan(duration_ms=5000, interval_us=30000, window_us=30000, act # Either from scan result device = result.device # Or with known address -device = aioble.Device(aioble.PUBLIC, "aa:bb:cc:dd:ee:ff") +device = aioble.Device(aioble.ADDR_PUBLIC, "aa:bb:cc:dd:ee:ff") try: connection = await device.connect(timeout_ms=2000) From 97881098729c2ba9f97edb96d65ebe4ec91aa25e Mon Sep 17 00:00:00 2001 From: Jos Verlinde Date: Thu, 13 Nov 2025 02:04:34 +0100 Subject: [PATCH 3/5] python-stdlib/copy/copy: Fix typo in _deepcopy_dispatch. closes: https://github.com/micropython/micropython-lib/issues/952 Signed-off-by: Jos Verlinde --- python-stdlib/copy/copy.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python-stdlib/copy/copy.py b/python-stdlib/copy/copy.py index 0a9283777..9d56d6cbd 100644 --- a/python-stdlib/copy/copy.py +++ b/python-stdlib/copy/copy.py @@ -191,7 +191,7 @@ def deepcopy(x, memo=None, _nil=[]): if copier: y = copier(memo) else: - reductor = dispatch_table.get(cls) + reductor = _deepcopy_dispatch.get(cls) if reductor: rv = reductor(x) else: From 66a6b1118e6a7539720c0bb2e2cfe1b5c114b8cd Mon Sep 17 00:00:00 2001 From: Jos Verlinde Date: Thu, 13 Nov 2025 02:33:58 +0100 Subject: [PATCH 4/5] requests/example_quote: Update example for fetching using requests. This is a working alternative to PR #919 closes: #919 Signed-off-by: Jos Verlinde --- python-ecosys/requests/{example_xively.py => example_quote.py} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename python-ecosys/requests/{example_xively.py => example_quote.py} (85%) diff --git a/python-ecosys/requests/example_xively.py b/python-ecosys/requests/example_quote.py similarity index 85% rename from python-ecosys/requests/example_xively.py rename to python-ecosys/requests/example_quote.py index 60e139b98..cfbe8ac0e 100644 --- a/python-ecosys/requests/example_xively.py +++ b/python-ecosys/requests/example_quote.py @@ -1,6 +1,6 @@ import requests -r = requests.get("http://api.xively.com/") +r = requests.get("https://dummyjson.com/quotes/1") print(r) print(r.content) print(r.text) From 555aa95fd982ae0c3479a61991c472157c547722 Mon Sep 17 00:00:00 2001 From: Jos Verlinde Date: Sat, 15 Nov 2025 22:58:10 +0100 Subject: [PATCH 5/5] Docs: Fix formatting errors in docstrings. Bumped patch level in manifest for each changed module Signed-off-by: Jos Verlinde --- micropython/drivers/imu/bmi270/bmi270.py | 36 +++++++++---------- micropython/drivers/imu/bmi270/manifest.py | 2 +- micropython/drivers/imu/bmm150/bmm150.py | 24 ++++++------- micropython/drivers/imu/bmm150/manifest.py | 2 +- micropython/drivers/imu/lsm6dsox/lsm6dsox.py | 26 +++++++------- micropython/drivers/imu/lsm6dsox/manifest.py | 2 +- micropython/drivers/imu/lsm9ds1/lsm9ds1.py | 24 ++++++------- micropython/drivers/imu/lsm9ds1/manifest.py | 2 +- micropython/drivers/sensor/ds18x20/ds18x20.py | 6 ++-- .../drivers/sensor/ds18x20/manifest.py | 2 +- micropython/drivers/sensor/hs3003/hs3003.py | 22 ++++++------ micropython/drivers/sensor/hs3003/manifest.py | 2 +- micropython/drivers/sensor/hts221/hts221.py | 22 ++++++------ micropython/drivers/sensor/hts221/manifest.py | 2 +- python-stdlib/cmd/cmd.py | 24 ++++++------- python-stdlib/cmd/manifest.py | 2 +- python-stdlib/contextlib/contextlib.py | 4 +-- python-stdlib/contextlib/manifest.py | 2 +- python-stdlib/heapq/heapq.py | 25 ++++++------- python-stdlib/heapq/manifest.py | 4 +-- python-stdlib/textwrap/manifest.py | 2 +- python-stdlib/textwrap/textwrap.py | 3 +- 22 files changed, 124 insertions(+), 116 deletions(-) diff --git a/micropython/drivers/imu/bmi270/bmi270.py b/micropython/drivers/imu/bmi270/bmi270.py index 64f819ec2..58e1a5344 100644 --- a/micropython/drivers/imu/bmi270/bmi270.py +++ b/micropython/drivers/imu/bmi270/bmi270.py @@ -21,25 +21,25 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -Basic example usage: +Basic example usage:: -import time -from bmi270 import BMI270 -from machine import Pin, SPI, I2C - -# Init in I2C mode. -imu = BMI270(I2C(1, scl=Pin(15), sda=Pin(14))) - -# Or init in SPI mode. -# TODO: Not supported yet. -# imu = BMI270(SPI(5), cs=Pin(10)) - -while (True): - print('Accelerometer: x:{:>6.3f} y:{:>6.3f} z:{:>6.3f}'.format(*imu.accel())) - print('Gyroscope: x:{:>6.3f} y:{:>6.3f} z:{:>6.3f}'.format(*imu.gyro())) - print('Magnetometer: x:{:>8.3f} y:{:>8.3f} z:{:>8.3f}'.format(*imu.magnet())) - print("") - time.sleep_ms(100) + import time + from bmi270 import BMI270 + from machine import Pin, SPI, I2C + + # Init in I2C mode. + imu = BMI270(I2C(1, scl=Pin(15), sda=Pin(14))) + + # Or init in SPI mode. + # TODO: Not supported yet. + # imu = BMI270(SPI(5), cs=Pin(10)) + + while (True): + print('Accelerometer: x:{:>6.3f} y:{:>6.3f} z:{:>6.3f}'.format(*imu.accel())) + print('Gyroscope: x:{:>6.3f} y:{:>6.3f} z:{:>6.3f}'.format(*imu.gyro())) + print('Magnetometer: x:{:>8.3f} y:{:>8.3f} z:{:>8.3f}'.format(*imu.magnet())) + print("") + time.sleep_ms(100) """ import array diff --git a/micropython/drivers/imu/bmi270/manifest.py b/micropython/drivers/imu/bmi270/manifest.py index 2d89bfe9d..e57d8ad0e 100644 --- a/micropython/drivers/imu/bmi270/manifest.py +++ b/micropython/drivers/imu/bmi270/manifest.py @@ -1,2 +1,2 @@ -metadata(description="BOSCH BMI270 IMU driver.", version="1.0.0") +metadata(description="BOSCH BMI270 IMU driver.", version="1.0.1") module("bmi270.py", opt=3) diff --git a/micropython/drivers/imu/bmm150/bmm150.py b/micropython/drivers/imu/bmm150/bmm150.py index a4845c961..aea4348b5 100644 --- a/micropython/drivers/imu/bmm150/bmm150.py +++ b/micropython/drivers/imu/bmm150/bmm150.py @@ -21,22 +21,22 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -Basic example usage: +Basic example usage:: -import time -from bmm150 import BMM150 -from machine import Pin, SPI, I2C + import time + from bmm150 import BMM150 + from machine import Pin, SPI, I2C -# Init in I2C mode. -imu = BMM150(I2C(1, scl=Pin(15), sda=Pin(14))) + # Init in I2C mode. + imu = BMM150(I2C(1, scl=Pin(15), sda=Pin(14))) -# Or init in SPI mode. -# TODO: Not supported yet. -# imu = BMM150(SPI(5), cs=Pin(10)) + # Or init in SPI mode. + # TODO: Not supported yet. + # imu = BMM150(SPI(5), cs=Pin(10)) -while (True): - print('magnetometer: x:{:>8.3f} y:{:>8.3f} z:{:>8.3f}'.format(*imu.magnet())) - time.sleep_ms(100) + while (True): + print('magnetometer: x:{:>8.3f} y:{:>8.3f} z:{:>8.3f}'.format(*imu.magnet())) + time.sleep_ms(100) """ import array diff --git a/micropython/drivers/imu/bmm150/manifest.py b/micropython/drivers/imu/bmm150/manifest.py index e9c7cf66b..b10792803 100644 --- a/micropython/drivers/imu/bmm150/manifest.py +++ b/micropython/drivers/imu/bmm150/manifest.py @@ -1,2 +1,2 @@ -metadata(description="BOSCH BMM150 magnetometer driver.", version="1.0.0") +metadata(description="BOSCH BMM150 magnetometer driver.", version="1.0.1") module("bmm150.py", opt=3) diff --git a/micropython/drivers/imu/lsm6dsox/lsm6dsox.py b/micropython/drivers/imu/lsm6dsox/lsm6dsox.py index ca1397c66..4787f12b4 100644 --- a/micropython/drivers/imu/lsm6dsox/lsm6dsox.py +++ b/micropython/drivers/imu/lsm6dsox/lsm6dsox.py @@ -25,23 +25,23 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -Basic example usage: +Basic example usage:: -import time -from lsm6dsox import LSM6DSOX + import time + from lsm6dsox import LSM6DSOX -from machine import Pin, SPI, I2C -# Init in I2C mode. -lsm = LSM6DSOX(I2C(0, scl=Pin(13), sda=Pin(12))) + from machine import Pin, SPI, I2C + # Init in I2C mode. + lsm = LSM6DSOX(I2C(0, scl=Pin(13), sda=Pin(12))) -# Or init in SPI mode. -#lsm = LSM6DSOX(SPI(5), cs=Pin(10)) + # Or init in SPI mode. + #lsm = LSM6DSOX(SPI(5), cs=Pin(10)) -while (True): - print('Accelerometer: x:{:>8.3f} y:{:>8.3f} z:{:>8.3f}'.format(*lsm.accel())) - print('Gyroscope: x:{:>8.3f} y:{:>8.3f} z:{:>8.3f}'.format(*lsm.gyro())) - print("") - time.sleep_ms(100) + while (True): + print('Accelerometer: x:{:>8.3f} y:{:>8.3f} z:{:>8.3f}'.format(*lsm.accel())) + print('Gyroscope: x:{:>8.3f} y:{:>8.3f} z:{:>8.3f}'.format(*lsm.gyro())) + print("") + time.sleep_ms(100) """ import array diff --git a/micropython/drivers/imu/lsm6dsox/manifest.py b/micropython/drivers/imu/lsm6dsox/manifest.py index 346255fe7..53fa4edf7 100644 --- a/micropython/drivers/imu/lsm6dsox/manifest.py +++ b/micropython/drivers/imu/lsm6dsox/manifest.py @@ -1,2 +1,2 @@ -metadata(description="ST LSM6DSOX imu driver.", version="1.0.1") +metadata(description="ST LSM6DSOX imu driver.", version="1.0.2") module("lsm6dsox.py", opt=3) diff --git a/micropython/drivers/imu/lsm9ds1/lsm9ds1.py b/micropython/drivers/imu/lsm9ds1/lsm9ds1.py index e5a96ad5c..a45e73039 100644 --- a/micropython/drivers/imu/lsm9ds1/lsm9ds1.py +++ b/micropython/drivers/imu/lsm9ds1/lsm9ds1.py @@ -27,21 +27,21 @@ The sensor contains an accelerometer / gyroscope / magnetometer Uses the internal FIFO to store up to 16 gyro/accel data, use the iter_accel_gyro generator to access it. -Example usage: +Example usage:: -import time -from lsm9ds1 import LSM9DS1 -from machine import Pin, I2C + import time + from lsm9ds1 import LSM9DS1 + from machine import Pin, I2C -imu = LSM9DS1(I2C(1, scl=Pin(15), sda=Pin(14))) + imu = LSM9DS1(I2C(1, scl=Pin(15), sda=Pin(14))) -while (True): - #for g,a in imu.iter_accel_gyro(): print(g,a) # using fifo - print('Accelerometer: x:{:>8.3f} y:{:>8.3f} z:{:>8.3f}'.format(*imu.accel())) - print('Magnetometer: x:{:>8.3f} y:{:>8.3f} z:{:>8.3f}'.format(*imu.magnet())) - print('Gyroscope: x:{:>8.3f} y:{:>8.3f} z:{:>8.3f}'.format(*imu.gyro())) - print("") - time.sleep_ms(100) + while (True): + #for g,a in imu.iter_accel_gyro(): print(g,a) # using fifo + print('Accelerometer: x:{:>8.3f} y:{:>8.3f} z:{:>8.3f}'.format(*imu.accel())) + print('Magnetometer: x:{:>8.3f} y:{:>8.3f} z:{:>8.3f}'.format(*imu.magnet())) + print('Gyroscope: x:{:>8.3f} y:{:>8.3f} z:{:>8.3f}'.format(*imu.gyro())) + print("") + time.sleep_ms(100) """ import array diff --git a/micropython/drivers/imu/lsm9ds1/manifest.py b/micropython/drivers/imu/lsm9ds1/manifest.py index c15c914b3..2e3783ee8 100644 --- a/micropython/drivers/imu/lsm9ds1/manifest.py +++ b/micropython/drivers/imu/lsm9ds1/manifest.py @@ -1,2 +1,2 @@ -metadata(description="Driver for ST LSM9DS1 IMU.", version="1.0.0") +metadata(description="Driver for ST LSM9DS1 IMU.", version="1.0.1") module("lsm9ds1.py", opt=3) diff --git a/micropython/drivers/sensor/ds18x20/ds18x20.py b/micropython/drivers/sensor/ds18x20/ds18x20.py index ad2d9f52c..543c6de1a 100644 --- a/micropython/drivers/sensor/ds18x20/ds18x20.py +++ b/micropython/drivers/sensor/ds18x20/ds18x20.py @@ -1,5 +1,7 @@ -# DS18x20 temperature sensor driver for MicroPython. -# MIT license; Copyright (c) 2016 Damien P. George +"""DS18x20 temperature sensor driver for MicroPython. + +MIT license; Copyright (c) 2016 Damien P. George +""" from micropython import const diff --git a/micropython/drivers/sensor/ds18x20/manifest.py b/micropython/drivers/sensor/ds18x20/manifest.py index 6ced882f7..411392b35 100644 --- a/micropython/drivers/sensor/ds18x20/manifest.py +++ b/micropython/drivers/sensor/ds18x20/manifest.py @@ -1,4 +1,4 @@ -metadata(description="DS18x20 temperature sensor driver.", version="0.1.0") +metadata(description="DS18x20 temperature sensor driver.", version="0.1.1") require("onewire") module("ds18x20.py", opt=3) diff --git a/micropython/drivers/sensor/hs3003/hs3003.py b/micropython/drivers/sensor/hs3003/hs3003.py index 003501649..332df8de7 100644 --- a/micropython/drivers/sensor/hs3003/hs3003.py +++ b/micropython/drivers/sensor/hs3003/hs3003.py @@ -22,21 +22,23 @@ THE SOFTWARE. HS3003 driver for MicroPython. +------------------------------ Example usage: -import time -from hs3003 import HS3003 -from machine import Pin, I2C + import time + from hs3003 import HS3003 + from machine import Pin, I2C -bus = I2C(1, scl=Pin(15), sda=Pin(14)) -hts = HS3003(bus) + bus = I2C(1, scl=Pin(15), sda=Pin(14)) + hts = HS3003(bus) + + while True: + rH = hts.humidity() + temp = hts.temperature() + print ("rH: %.2f%% T: %.2fC" %(rH, temp)) + time.sleep_ms(100) -while True: - rH = hts.humidity() - temp = hts.temperature() - print ("rH: %.2f%% T: %.2fC" %(rH, temp)) - time.sleep_ms(100) """ import struct diff --git a/micropython/drivers/sensor/hs3003/manifest.py b/micropython/drivers/sensor/hs3003/manifest.py index 8409c76d8..60b0877de 100644 --- a/micropython/drivers/sensor/hs3003/manifest.py +++ b/micropython/drivers/sensor/hs3003/manifest.py @@ -1,2 +1,2 @@ -metadata(description="Renesas HS3003 Humidity and Temperature sensor driver.", version="1.0.0") +metadata(description="Renesas HS3003 Humidity and Temperature sensor driver.", version="1.0.1") module("hs3003.py", opt=3) diff --git a/micropython/drivers/sensor/hts221/hts221.py b/micropython/drivers/sensor/hts221/hts221.py index c6cd51f48..5be268d40 100644 --- a/micropython/drivers/sensor/hts221/hts221.py +++ b/micropython/drivers/sensor/hts221/hts221.py @@ -23,22 +23,24 @@ THE SOFTWARE. HTS221 driver driver for MicroPython. +------------------------------------- + Original source: https://github.com/ControlEverythingCommunity/HTS221/blob/master/Python/HTS221.py Example usage: -import time -import hts221 -from machine import Pin, I2C + import time + import hts221 + from machine import Pin, I2C -bus = I2C(1, scl=Pin(15), sda=Pin(14)) -hts = hts221.HTS221(bus) + bus = I2C(1, scl=Pin(15), sda=Pin(14)) + hts = hts221.HTS221(bus) -while (True): - rH = hts.humidity() - temp = hts.temperature() - print ("rH: %.2f%% T: %.2fC" %(rH, temp)) - time.sleep_ms(100) + while (True): + rH = hts.humidity() + temp = hts.temperature() + print ("rH: %.2f%% T: %.2fC" %(rH, temp)) + time.sleep_ms(100) """ import struct diff --git a/micropython/drivers/sensor/hts221/manifest.py b/micropython/drivers/sensor/hts221/manifest.py index d85edaac8..983086fe2 100644 --- a/micropython/drivers/sensor/hts221/manifest.py +++ b/micropython/drivers/sensor/hts221/manifest.py @@ -1,3 +1,3 @@ -metadata(description="HTS221 temperature/humidity sensor driver.", version="0.1.0") +metadata(description="HTS221 temperature/humidity sensor driver.", version="0.1.1") module("hts221.py", opt=3) diff --git a/python-stdlib/cmd/cmd.py b/python-stdlib/cmd/cmd.py index 447ea1489..b815cba36 100644 --- a/python-stdlib/cmd/cmd.py +++ b/python-stdlib/cmd/cmd.py @@ -5,16 +5,16 @@ 1. End of file on input is processed as the command 'EOF'. 2. A command is parsed out of each line by collecting the prefix composed of characters in the identchars member. -3. A command `foo' is dispatched to a method 'do_foo()'; the do_ method +3. A command 'foo' is dispatched to a method 'do_foo()'; the do_ method is passed a single argument consisting of the remainder of the line. 4. Typing an empty line repeats the last command. (Actually, it calls the - method `emptyline', which may be overridden in a subclass.) -5. There is a predefined `help' method. Given an argument `topic', it - calls the command `help_topic'. With no arguments, it lists all topics + method 'emptyline', which may be overridden in a subclass.) +5. There is a predefined 'help' method. Given an argument 'topic', it + calls the command 'help_topic'. With no arguments, it lists all topics with defined help_ functions, broken into up to three topics; documented commands, miscellaneous help topics, and undocumented commands. -6. The command '?' is a synonym for `help'. The command '!' is a synonym - for `shell', if a do_shell method exists. +6. The command '?' is a synonym for 'help'. The command '!' is a synonym + for 'shell', if a do_shell method exists. 7. If completion is enabled, completing commands will be done automatically, and completing of commands args is done by calling complete_foo() with arguments text, line, begidx, endidx. text is string we are matching @@ -23,21 +23,21 @@ indexes of the text being matched, which could be used to provide different completion depending upon which position the argument is in. -The `default' method may be overridden to intercept commands for which there +The 'default' method may be overridden to intercept commands for which there is no do_ method. -The `completedefault' method may be overridden to intercept completions for +The 'completedefault' method may be overridden to intercept completions for commands that have no complete_ method. -The data member `self.ruler' sets the character used to draw separator lines +The data member 'self.ruler' sets the character used to draw separator lines in the help messages. If empty, no ruler line is drawn. It defaults to "=". -If the value of `self.intro' is nonempty when the cmdloop method is called, +If the value of 'self.intro' is nonempty when the cmdloop method is called, it is printed out on interpreter startup. This value may be overridden via an optional argument to the cmdloop() method. -The data members `self.doc_header', `self.misc_header', and -`self.undoc_header' set the headers used for the help function's +The data members 'self.doc_header', 'self.misc_header', and +'self.undoc_header' set the headers used for the help function's listings of documented functions, miscellaneous topics, and undocumented functions respectively. diff --git a/python-stdlib/cmd/manifest.py b/python-stdlib/cmd/manifest.py index 910352ee7..6a5579e9d 100644 --- a/python-stdlib/cmd/manifest.py +++ b/python-stdlib/cmd/manifest.py @@ -1,3 +1,3 @@ -metadata(version="3.4.1") +metadata(version="3.4.2") module("cmd.py") diff --git a/python-stdlib/contextlib/contextlib.py b/python-stdlib/contextlib/contextlib.py index 3e598b4b6..c02ba1ef8 100644 --- a/python-stdlib/contextlib/contextlib.py +++ b/python-stdlib/contextlib/contextlib.py @@ -15,12 +15,12 @@ class closing(object): """Context to automatically close something at the end of a block. - Code like this: + Code like this:: with closing(.open()) as f: - is equivalent to this: + is equivalent to this:: f = .open() try: diff --git a/python-stdlib/contextlib/manifest.py b/python-stdlib/contextlib/manifest.py index 3e05bca18..bb8d48674 100644 --- a/python-stdlib/contextlib/manifest.py +++ b/python-stdlib/contextlib/manifest.py @@ -1,4 +1,4 @@ -metadata(description="Port of contextlib for micropython", version="3.4.4") +metadata(description="Port of contextlib for MicroPython", version="3.4.5") require("ucontextlib") require("collections") diff --git a/python-stdlib/heapq/heapq.py b/python-stdlib/heapq/heapq.py index b11853b8d..f1957a186 100644 --- a/python-stdlib/heapq/heapq.py +++ b/python-stdlib/heapq/heapq.py @@ -1,4 +1,5 @@ -"""Heap queue algorithm (a.k.a. priority queue). +""" +Heap queue algorithm (a.k.a. priority queue). Heaps are arrays for which a[k] <= a[2*k+1] and a[k] <= a[2*k+2] for all k, counting elements from 0. For the sake of comparison, @@ -7,13 +8,13 @@ Usage: -heap = [] # creates an empty heap -heappush(heap, item) # pushes a new item on the heap -item = heappop(heap) # pops the smallest item from the heap -item = heap[0] # smallest item on the heap without popping it -heapify(x) # transforms list into a heap, in-place, in linear time -item = heapreplace(heap, item) # pops and returns smallest item, and adds - # new item; the heap size is unchanged + heap = [] # creates an empty heap + heappush(heap, item) # pushes a new item on the heap + item = heappop(heap) # pops the smallest item from the heap + item = heap[0] # smallest item on the heap without popping it + heapify(x) # transforms list into a heap, in-place, in linear time + item = heapreplace(heap, item) # pops and returns smallest item, and adds + # new item; the heap size is unchanged Our API differs from textbook heap algorithms as follows: @@ -40,7 +41,7 @@ property of a heap is that a[0] is always its smallest element. The strange invariant above is meant to be an efficient memory -representation for a tournament. The numbers below are `k', not a[k]: +representation for a tournament. The numbers below are 'k', not a[k]:: 0 @@ -53,7 +54,7 @@ 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 -In the tree above, each cell `k' is topping `2*k+1' and `2*k+2'. In +In the tree above, each cell 'k' is topping '2*k+1' and '2*k+2'. In an usual binary tournament we see in sports, each cell is the winner over the two cells it tops, and we can trace the winner down the tree to see all opponents s/he had. However, in many computer applications @@ -108,7 +109,7 @@ effective! In a word, heaps are useful memory structures to know. I use them in -a few applications, and I think it is good to keep a `heap' module +a few applications, and I think it is good to keep a `heap` module around. :-) -------------------- @@ -377,7 +378,7 @@ def _siftup_max(heap, pos): def merge(*iterables): """Merge multiple sorted inputs into a single sorted output. - Similar to sorted(itertools.chain(*iterables)) but returns a generator, + Similar to `sorted(itertools.chain(*iterables))` but returns a generator, does not pull the data into memory all at once, and assumes that each of the input streams is already sorted (smallest to largest). diff --git a/python-stdlib/heapq/manifest.py b/python-stdlib/heapq/manifest.py index 1d71a3180..906f84a5b 100644 --- a/python-stdlib/heapq/manifest.py +++ b/python-stdlib/heapq/manifest.py @@ -1,3 +1,3 @@ -metadata(version="0.9.3") +metadata(version="0.9.5") -module("heapq.py") +module("heapq.py") \ No newline at end of file diff --git a/python-stdlib/textwrap/manifest.py b/python-stdlib/textwrap/manifest.py index e287ac395..d2b51e201 100644 --- a/python-stdlib/textwrap/manifest.py +++ b/python-stdlib/textwrap/manifest.py @@ -1,3 +1,3 @@ -metadata(version="3.4.3") +metadata(version="3.4.5") module("textwrap.py") diff --git a/python-stdlib/textwrap/textwrap.py b/python-stdlib/textwrap/textwrap.py index 4e9f35069..89f4a111c 100644 --- a/python-stdlib/textwrap/textwrap.py +++ b/python-stdlib/textwrap/textwrap.py @@ -169,7 +169,8 @@ def _split(self, text): return chunks def _fix_sentence_endings(self, chunks): - """_fix_sentence_endings(chunks : [string]) + """ + _fix_sentence_endings(chunks : [string]) Correct for sentence endings buried in 'chunks'. Eg. when the original text contains "... foo.\nBar ...", munge_whitespace()