Skip to content

Commit 13e0828

Browse files
updated code examples for chapters
1 parent 6b16f68 commit 13e0828

11 files changed

Lines changed: 6 additions & 34 deletions

‎src/16_gil_array_fill/01_fill_array_ones.py‎

Lines changed: 0 additions & 13 deletions
This file was deleted.
File renamed without changes.

src/16_gil_array_fill/04_fill_multithreaded_default.py renamed to src/16_gil_array_fill/02_fill_multithreaded_default.py

File renamed without changes.
File renamed without changes.

‎src/16_gil_array_fill/03_create_and_assign.py‎

Lines changed: 0 additions & 15 deletions
This file was deleted.

src/19_gil_random_fill/01_create_vector_random_numbers.py renamed to src/19_gil_random_fill/01_create_concat_singlethreaded.py

File renamed without changes.

src/19_gil_random_fill/03_create_vector_threads.py renamed to src/19_gil_random_fill/02_create_concat_multithreaded.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from numpy.random import default_rng
99

1010
# create and return an array of random numbers
11-
def populate(seed, size):
11+
def create_array(seed, size):
1212
# create random number generator with the seed
1313
rand = default_rng(seed)
1414
# create array of random floats
@@ -28,7 +28,7 @@ def populate(seed, size):
2828
size = int(ceil(n / n_workers))
2929
# issue all tasks and gather results
3030
sizes = [size for _ in seeds]
31-
result_list = list(exe.map(populate, seeds, sizes))
31+
result_list = list(exe.map(create_array, seeds, sizes))
3232
# convert list of arrays into one large array
3333
result = concatenate(result_list)
3434
# calculate and report duration

src/19_gil_random_fill/02_populate_vector_random_numbers.py renamed to src/19_gil_random_fill/03_create_populae_singlethreaded.py

File renamed without changes.

src/19_gil_random_fill/04_populate_vector_threads.py renamed to src/19_gil_random_fill/04_create_populate_multithreaded.py

File renamed without changes.

‎src/30_shared_array_memory_mapped/01_share_array_mmapped_file.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
# load shared array
77
def task(filename, n):
8-
# load the memory mapped file
8+
# load the memory-mapped file
99
data = memmap(filename,
1010
dtype='float32', mode='r+', shape=(n,))
1111
# check the status of the data
@@ -23,7 +23,7 @@ def task(filename, n):
2323
n = 1000
2424
# define the filename
2525
filename = 'data.np'
26-
# create the memory mapped file
26+
# create the memory-mapped file
2727
data = memmap(filename,
2828
dtype='float32', mode='w+', shape=(n,))
2929
# populate the array

0 commit comments

Comments
 (0)