Skip to content

Commit

Permalink
🐛 Fix unintentional memory usage regression when using large payload …
Browse files Browse the repository at this point in the history
…that match several encoding (#376)
  • Loading branch information
Ousret committed Oct 31, 2023
1 parent 07f3041 commit 1f3cac5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
All notable changes to charset-normalizer will be documented in this file. This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## [3.3.2](https://github.com/Ousret/charset_normalizer/compare/3.3.1...3.3.2) (2023-10-31)

### Fixed
- Unintentional memory usage regression when using large payload that match several encoding (#376)


## [3.3.1](https://github.com/Ousret/charset_normalizer/compare/3.3.0...3.3.1) (2023-10-22)

### Changed
Expand Down
3 changes: 3 additions & 0 deletions charset_normalizer/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ def __lt__(self, other: object) -> bool:
return self.coherence > other.coherence
elif chaos_difference < 0.01 and coherence_difference <= 0.02:
# When having a difficult decision, use the result that decoded as many multi-byte as possible.
# preserve RAM usage!
if len(self._payload) >= TOO_BIG_SEQUENCE:
return self.chaos < other.chaos
return self.multi_byte_usage > other.multi_byte_usage

return self.chaos < other.chaos
Expand Down
2 changes: 1 addition & 1 deletion charset_normalizer/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
Expose version
"""

__version__ = "3.3.1"
__version__ = "3.3.2"
VERSION = __version__.split(".")

0 comments on commit 1f3cac5

Please sign in to comment.