Skip to content

Commit

Permalink
Merge pull request python-pillow#7665 from hugovk/update-release-notes
Browse files Browse the repository at this point in the history
Release notes: add `ImageColor` and `ImageMode` optimisations, and type hints
  • Loading branch information
radarhere authored Jan 1, 2024
2 parents c7a1ce1 + ea4fde8 commit 1469e43
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 10 deletions.
8 changes: 8 additions & 0 deletions docs/PIL.rst
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,14 @@ can be found here.
:undoc-members:
:show-inheritance:

:mod:`~PIL.ImageMode` Module
----------------------------

.. automodule:: PIL.ImageMode
:members:
:undoc-members:
:show-inheritance:

:mod:`~PIL.ImageTransform` Module
---------------------------------

Expand Down
39 changes: 29 additions & 10 deletions docs/releasenotes/10.2.0.rst
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
10.2.0
------

Backwards Incompatible Changes
==============================

TODO
^^^^

TODO

Deprecations
============

Expand Down Expand Up @@ -118,16 +110,43 @@ Saving TIFF tag RowsPerStrip
When saving TIFF images, the TIFF tag RowsPerStrip can now be one of the tags set by
the user, rather than always being calculated by Pillow.

Optimized ImageColor.getrgb and getcolor
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

The color calculations of :py:attr:`~PIL.ImageColor.getrgb` and
:py:attr:`~PIL.ImageColor.getcolor` are now cached using
:py:func:`functools.lru_cache`. Cached calls of ``getrgb`` are 3.1 - 91.4 times
as fast and ``getcolor`` are 5.1 - 19.6 times as fast.

Optimized ImageMode.getmode
^^^^^^^^^^^^^^^^^^^^^^^^^^^

The lookups made by :py:attr:`~PIL.ImageMode.getmode` are now cached using
:py:func:`functools.lru_cache` instead of a custom cache. Cached calls are 1.2 times as
fast.

Optimized ImageStat.Stat count and extrema
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Calculating the :py:attr:`~PIL.ImageStat.Stat.count` and
:py:attr:`~PIL.ImageStat.Stat.extrema` statistics is now faster. After the
histogram is created in ``st = ImageStat.Stat(im)``, ``st.count`` is 3x as fast
on average and ``st.extrema`` is 12x as fast on average.
histogram is created in ``st = ImageStat.Stat(im)``, ``st.count`` is 3 times as fast on
average and ``st.extrema`` is 12 times as fast on average.

Encoder errors now report error detail as string
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

:py:exc:`OSError` exceptions from image encoders now include a textual description of
the error instead of a numeric error code.

Type hints
^^^^^^^^^^

Work has begun to add type annotations to Pillow, including:

* :py:mod:`~PIL.ContainerIO`
* :py:mod:`~PIL.FontFile`, :py:mod:`~PIL.BdfFontFile` and :py:mod:`~PIL.PcfFontFile`
* :py:mod:`~PIL.ImageChops`
* :py:mod:`~PIL.ImageMode`
* :py:mod:`~PIL.ImageSequence`
* :py:mod:`~PIL.TarIO`

0 comments on commit 1469e43

Please sign in to comment.