Errata

High Performance Python

Errata for High Performance Python

Submit your own errata for this product.

The errata list is a list of errors and their corrections that were found after the product was released.

The following errata were submitted by our customers and have not yet been approved or disproved by the author or editor. They solely represent the opinion of the customer.

Color Key: Serious technical mistake Minor technical mistake Language or formatting error Typo Question Note Update

Version Location Description Submitted by Date submitted
Printed Page 41
last pargraph before and first few lines of Example 2-6

"Without -v, you receive an .lprof output ..."

Since there is no "only", the clear implication is that you would not generate a .lprof file if you did specify -v. However:

"$kernprof -l -v julia1_lineprofiler.py.lprof
...
Wrote profile results to julia1_lineprofiler.py.lprof"

Gregory Sherman  Apr 30, 2021 
Printed Page 45
Example 2-9

The kernprof command and the first couple of lines output by the run are missing.

Gregory Sherman  Apr 30, 2021 
Printed Page 55
both py-spy command lines

$ sudo env "PATH=$PATH" py-spy --pid 15953

There is no explanation in the text of why an environment variable needs to be set, and I found nothing in the "--help" of the py-spy command. The command would not work in version 0.3.5 of py-spy. Apparently, it needs to be:
py-spy top --pid 15953

=======================================================
$ py-spy --flame profile.svg -- python julia1_nopil.py

This also does not run, but I can't get it work as it seems to be intended (with no process id specified). There is a space between "--" and "python" that may be a typo. Neither "sudo" nor "PATH" precedes this call, but no explanation is given.

On my Windows 10 PC, I can get a result like the one in the text with:
py-spy record --output profile.svg --pid 5780
where 5780 is the process id of the python.exe instance running the python program


Gregory Sherman  May 01, 2021 
Printed Page 71
Second bullet point

The statement that tuples are immutable should be qualified. Arguably, the content of tup = (5, [6]) can be changed, by doing tup[1].append(7). This has an important implication in terms of hashability.

Anonymous  Aug 28, 2020 
Printed Page 88
Third sentence of "Hash Functions and Entropy" section

"Tuples [...] have a hash value that is based on their contents." Not true, since not all tuples have a hash value.

tup = (2, [3])
s = set(tup)
Traceback (most recent call last):
File "<input>", line 1, in <module>
TypeError: unhashable type: 'list'

Anonymous  Aug 28, 2020 
Printed Page 88,90,92
dictionary sizes

How can the following snippets all be correct?

pg 88: "... following possible sizes
8; 18; 39; 81; 165; 333; 669; 1,341; 2,685..."

pg 90: "... the smallest dictionary size ... (8; 32; 128; 512; 2,048; etc.) ..."

pg. 92: "... a hash table of size 1,024 ..."

Gregory Sherman  May 03, 2021 
Printed Page 90
General note in the middle of the page

"We first find the minimum number of buckets that tictionary must have to still be two-thirds full (N*(2/3+1))"

Wouldn't such number be N*(1/2+1)?

"Then we find the smallest dictionary size that will hold this number of elements (8;32; [...])"

Suggest rephrasing as, "Then we find the smallest power of two that is bigger than this number".

"find the number of bits necessary to hold this number."

Suggest rephrasing as, "find the number of bits necessary to represent this number." And perhaps mention that it's log2(x).

Anonymous  Aug 28, 2020 
Printed Page 90
3rd paragraph

Reads "... for a dictionary with four elements, the mask we use is 0b111. Thus the hash value for the number 5 is 5 & 0b111 = 5 ..."

Presumably the mask for a dictionary of size 4 should be 0b11 so that 5 & 0b11 = 1, an index that fits into an array of 4 elements. Or the authors meant to write "... for a dictionary with eight elements ..."

Jackson Smith  Jun 14, 2023 
Printed Page 126, 127
"list" functions, explanatory text

"The difference in speed between the pure Python looping method and the list comprehension method shows the benefit of doing more calculations behind the scenes rather than explicitly in your Python code".

As can be seen on page 126, the "list_comprehension" function runs more quickly (apparently on a linux computer), but this is not seen when I run %timeit on my Windows 10 PC, where "list_comprehension()" takes 20+% more time. Any idea why?

Gregory Sherman  May 05, 2021 
Printed Page 132
last sentence

" ... vectorization accounts for only about 13% of that 66.3x speedup."

(17.339656586 - 2.274377105) / (143.935522122 - 2.274377105) =~ 10.6%

Gregory Sherman  May 06, 2021 
Printed Page 186
first 2 paragraphs

The first 2 paragraphs appear to be largely redundant.

first: "... PyPy supports projects like numpy that require C bindings through the CPython extension compatibility layer cpyext ... , but has an overhead of 4-6x, which generally makes numpy to slow."

second: "If you need other packages, they should install thanks to the cpyext compatibility module ... It handles the different memory management requirements of PyPy and CPython; however, this management incurs a cost of 4-6x per managed call, so the speed advantages of numpy can be negated by this overhead."

Gregory Sherman  May 09, 2021 
Printed Page 264,265
bullet points & text

"
* No use of multiprocessing (named "Serial")
* Using threads
* Using processes

The serial and single-worker versions ...
When using multiple processes ..."
========================================

Is "single-worker" supposed to signify using threads?


Gregory Sherman  Aug 02, 2021 
Printed Page 283
Figure 9-17

There are 4 methods listed in the box at the top left of the chart, but only 3 lines can be seen. This kind of problem is common with many line graphs in this book. It is often very difficult to figure out what a particular line means, as the lines do not differ enough in appearance as grayscale.

Gregory Sherman  Aug 10, 2021