Add errata entry

This commit is contained in:
Bogumił Kamiński 2023-03-03 19:25:23 +01:00 committed by GitHub
parent b29d4284f0
commit 65b2d85b8e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -175,6 +175,55 @@ Kamiński, Bogumił. 2023. *Julia for Data Analysis*. Manning.
## Errata
### Chapter 1, section 1.2.1, page 7
I show the following example of code execution:
```
julia> function sum_n(n)
s = 0
for i in 1:n
s += i
end
return s
end
sum_n (generic function with 1 method)
julia> @time sum_n(1_000_000_000)
0.000001 seconds
500000000500000000
```
This timining is very fast (and the reason is explained in the book).
The issue is that this is the situation under Julia 1.7.
Under Julia 1.8 and Julia 1.9 running the same code takes longer (tested under Julia 1.9-beta4):
```
julia> @time sum_n(1_000_000_000)
2.265569 seconds
500000000500000000
```
The reason for this inconsistency is a bug in `@time` macro introduced in Julia 1.8 release.
The `sum_n(1_000_000_000)` call (without `@time`) is executed fast.
Here is a simplified benchmark (run under Julia 1.9-beta4):
```
julia> let
start = time_ns()
v = sum_n(1_000_000_000)
stop=time_ns()
v, Int(stop - start)
end
(500000000500000000, 1000)
```
Unfortunately there is an issue with the `@time`
macro used in global scope, that needs to be resolved in Base Julia.
See [this issue](https://github.com/JuliaLang/julia/issues/47561).
### Chapter 2, section 2.3.1, page 30
I compare the following expressions: