Fix encode/decode errors in structs.#85
Closed
cykerway wants to merge 2 commits into
Closed
Conversation
The default encoding in Python 3 is 'utf-8', which is not a good choice for byte-level data pack/unpack because it uses multiple bytes for code point >= 128. This commit changes encoding being used to 'latin-1', which covers all possible code points in range (0-255) with a simple one-to-one mapping. This commit has fixed some *UnicodeDecodeError* in practice.
Codecov Report
@@ Coverage Diff @@
## master #85 +/- ##
=======================================
Coverage 81.25% 81.25%
=======================================
Files 39 39
Lines 4427 4427
=======================================
Hits 3597 3597
Misses 830 830 |
The `send_and_recv` function is very slow on receiving a large volume of data because it only receives 2048 bytes at a time and keeps appending these small chunks of data into a large array. This commit sets the recv buffer to a larger value. This has provable performance benefits: The running time of a Xlib program has been reduced from 12 seconds to 0.5 seconds, a 24x speedup.
Member
|
Closing this, for rational see: #84 (comment) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The default encoding in Python 3 is 'utf-8', which is not a good choice
for byte-level data pack/unpack because it uses multiple bytes for code
point >= 128.
This commit changes encoding being used to 'latin-1', which covers all
possible code points in range (0-255) with a simple one-to-one mapping.
This commit has fixed some UnicodeDecodeError in practice.