Repository navigation
Releases: dflook/python-minifier
Release list
3.4.0
ℹ️ Note that python-minifier depends on the python interpreter for parsing source code,
and will output source code compatible with the version of the interpreter it is run with.
This means that if you minify code written for Python 3.11 using python-minifier running with Python 3.12,
the minified code may only run with Python 3.12.
Added
- Python 3.15 support, including:
- PEP 810 lazy imports
- PEP 798 unpacking in comprehensions
Fixed
- The combine imports transform now combines all runs of
fromimports that can be combined.
Previously only a leading run of imports from the same module was combined.
3.3.0
ℹ️ Note that python-minifier depends on the python interpreter for parsing source code,
and will output source code compatible with the version of the interpreter it is run with.
This means that if you minify code written for Python 3.11 using python-minifier running with Python 3.12,
the minified code may only run with Python 3.12.
Added
- New transform to remove
ifstatement branches that have no effect because the condition is alwaysTrueorFalse. This is enabled by default and can be disabled with the--no-remove-dead-branchesoption. - Constant folding can now fold boolean (
and/or) and comparison (==,is,<, ...) expressions with literal operands.
Changed
- The remove pass, remove asserts, remove literal statements and combine imports transforms now also apply within
excepthandler andmatchcase bodies, where they were previously skipped.
Fixed
- The remove debug transform no longer removes branches if they affect the program, even though they aren't executed, e.g. they contain
yield, aglobal/nonlocaldeclaration, or the only binding of a local name. It also now properly inlines the else branch. - Fixed producing invalid output for a
matchcase guard that is a tuple,yield, or named expression, e.g.case x if (1, 2):. - Constant folding no longer emits a
DeprecationWarningwhen folding~on a boolean (e.g.~True) on Python 3.12 and later
3.2.0
ℹ️ Note that python-minifier depends on the python interpreter for parsing source code,
and will output source code compatible with the version of the interpreter it is run with.
This means that if you minify code written for Python 3.11 using python-minifier running with Python 3.12,
the minified code may only run with Python 3.12.
Added
- New
--prefer-single-lineoption to use semicolons instead of newlines between top-level statements when there is no difference in output size. This doesn't make the output any smaller, but may be preferred. - Constant folding can now fold unary operators (e.g.
-1,not True,~0) in addition to binary operators.
3.1.1
ℹ️ Note that python-minifier depends on the python interpreter for parsing source code,
and will output source code compatible with the version of the interpreter it is run with.
This means that if you minify code written for Python 3.11 using python-minifier running with Python 3.12,
the minified code may only run with Python 3.12.
Fixed
- The remove debug transform could incorrectly remove if branches that did not test
__debug__
3.1.0
ℹ️ Note that python-minifier depends on the python interpreter for parsing source code,
and will output source code compatible with the version of the interpreter it is run with.
This means that if you minify code written for Python 3.11 using python-minifier running with Python 3.12,
the minified code may only run with Python 3.12.
Added
- Python 3.14 support, including:
- PEP 750 Template strings (t-strings)
Fixed
- Failure to minify modules with special characters appearing in f-strings (e.g. null)
3.0.0
ℹ️ Note that python-minifier depends on the python interpreter for parsing source code,
and will output source code compatible with the version of the interpreter it is run with.
This means that if you minify code written for Python 3.11 using python-minifier running with Python 3.12,
the minified code may only run with Python 3.12.
Fixed
-
Better support of unicode on platforms that do not use UTF-8 as the default encoding.
This should fix issues with minifying files on Windows, and possibly other platforms with very old Python versions.If you are still using Python 2.7 this could be a breaking change - the pyminify command is unchanged, but the
minify()function now returns unicode strings.
2.11.3
ℹ️ Note that python-minifier depends on the python interpreter for parsing source code,
and will output source code compatible with the version of the interpreter it is run with.
This means that if you minify code written for Python 3.11 using python-minifier running with Python 3.12,
the minified code may only run with Python 3.12.
Fixed
-
The special behaviour of assignment expression target binding inside comprehensions was not correctly implemented.
This could lead to the analysed scope of these variables being incorrect and the variable being renamed to a name that was already in scope.
2.11.2
ℹ️ Note that python-minifier depends on the python interpreter for parsing source code,
and will output source code compatible with the version of the interpreter it is run with.
This means that if you minify code written for Python 3.11 using python-minifier running with Python 3.12,
the minified code may only run with Python 3.12.
Fixed
- Using the positional only parameter separator
/in method definitions could cause the following parameter to be
incorrectly renamed in place, which could lead to failure if the method was called with that parameter as a keyword argument.
This has been fixed.
2.11.1
ℹ️ Note that python-minifier depends on the python interpreter for parsing source code,
and will output source code compatible with the version of the interpreter it is run with.
This means that if you minify code written for Python 3.11 using python-minifier running with Python 3.12,
the minified code may only run with Python 3.12.
Fixed
- Using the
--remove-class-attribute-annotationsoption together with--rename-globalswas incorrectly causing class attributes to be renamed. Both of these options are unsafe for arbitrary code and are disabled by default but this was not the intended behavior, and has been fixed.
2.11.0
ℹ️ Note that python-minifier depends on the python interpreter for parsing source code,
and will output source code compatible with the version of the interpreter it is run with.
This means that if you minify code written for Python 3.11 using python-minifier running with Python 3.12,
the minified code may only run with Python 3.12.
Added
- Python 3.13 support, including:
- PEP 696 Type parameter defaults