Skip to content

Fix encode/decode errors in structs.#85

Closed
cykerway wants to merge 2 commits into
python-xlib:masterfrom
cykerway:master
Closed

Fix encode/decode errors in structs.#85
cykerway wants to merge 2 commits into
python-xlib:masterfrom
cykerway:master

Conversation

@cykerway

@cykerway cykerway commented Sep 3, 2017

Copy link
Copy Markdown

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.

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-io

codecov-io commented Sep 3, 2017

Copy link
Copy Markdown

Codecov Report

Merging #85 into master will not change coverage.
The diff coverage is 100%.

@@           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.
@benoit-pierre

Copy link
Copy Markdown
Member

Closing this, for rational see: #84 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants