Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release notes: add ImageColor and ImageMode optimisations, and type hints #7665

Merged
merged 8 commits into from
Jan 1, 2024
9 changes: 9 additions & 0 deletions docs/PIL.rst
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,15 @@ can be found here.
:undoc-members:
:show-inheritance:

:mod:`~PIL.ImageMode` Module
-----------------------------
hugovk marked this conversation as resolved.
Show resolved Hide resolved

.. automodule:: PIL.ImageMode
:members:
:member-order: bysource
hugovk marked this conversation as resolved.
Show resolved Hide resolved
:undoc-members:
:show-inheritance:

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

Expand Down
40 changes: 27 additions & 13 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 All @@ -20,11 +12,6 @@ ImageFile.raise_oserror
error codes returned by a codec's ``decode()`` method, which ImageFile already does
automatically.

TODO
^^^^

TODO

API Changes
===========

Expand Down Expand Up @@ -92,6 +79,21 @@ Support has been added to read the BC4U format of DDS images.
Support has also been added to read DX10 BC1 and BC4, whether UNORM or
TYPELESS.

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 20%
faster.

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

Expand All @@ -105,3 +107,15 @@ 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` and subclasses
hugovk marked this conversation as resolved.
Show resolved Hide resolved
* :py:mod:`~PIL.ImageChops`
* :py:mod:`~PIL.ImageMode`
* :py:mod:`~PIL.ImageSequence`
* :py:mod:`~PIL.TarIO`