Skip to content

Commit 59b91d9

Browse files
authored
Merge pull request #25 from gjbex/development
Updates to slides
2 parents 57ce312 + 15e766c commit 59b91d9

File tree

2 files changed

+78
-17
lines changed

2 files changed

+78
-17
lines changed

scientific_python.pptx

-828 Bytes
Binary file not shown.

source-code/numpy/io_performance.ipynb

+78-17
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@
107107
"name": "stdout",
108108
"output_type": "stream",
109109
"text": [
110-
"CPU times: user 11.2 s, sys: 173 ms, total: 11.3 s\n",
111-
"Wall time: 11.5 s\n"
110+
"CPU times: user 11.7 s, sys: 323 ms, total: 12 s\n",
111+
"Wall time: 12.2 s\n"
112112
]
113113
}
114114
],
@@ -142,7 +142,7 @@
142142
"name": "stdout",
143143
"output_type": "stream",
144144
"text": [
145-
"2.09 s ± 21.4 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)\n"
145+
"2.14 s ± 13.7 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)\n"
146146
]
147147
}
148148
],
@@ -195,7 +195,7 @@
195195
"name": "stdout",
196196
"output_type": "stream",
197197
"text": [
198-
"6.14 s ± 98.6 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)\n"
198+
"6.22 s ± 89.4 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)\n"
199199
]
200200
}
201201
],
@@ -248,7 +248,7 @@
248248
"name": "stdout",
249249
"output_type": "stream",
250250
"text": [
251-
"12.2 s ± 439 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)\n"
251+
"12.1 s ± 289 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)\n"
252252
]
253253
}
254254
],
@@ -347,15 +347,23 @@
347347
"name": "stdout",
348348
"output_type": "stream",
349349
"text": [
350-
"CPU times: user 0 ns, sys: 36.6 ms, total: 36.6 ms\n",
351-
"Wall time: 36.4 ms\n"
350+
"CPU times: user 8.4 ms, sys: 110 ms, total: 118 ms\n",
351+
"Wall time: 119 ms\n"
352352
]
353353
}
354354
],
355355
"source": [
356356
"%time np.save(bin_file_name, data)"
357357
]
358358
},
359+
{
360+
"cell_type": "markdown",
361+
"id": "3742048e-11ec-4ea0-80c6-acce043c3ffc",
362+
"metadata": {},
363+
"source": [
364+
"### `np.load`"
365+
]
366+
},
359367
{
360368
"cell_type": "code",
361369
"execution_count": 14,
@@ -366,7 +374,7 @@
366374
"name": "stdout",
367375
"output_type": "stream",
368376
"text": [
369-
"17.6 ms ± 922 μs per loop (mean ± std. dev. of 7 runs, 100 loops each)\n"
377+
"19.3 ms ± 2.65 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)\n"
370378
]
371379
}
372380
],
@@ -401,6 +409,59 @@
401409
"print(loaded_data.shape, loaded_data.dtype)"
402410
]
403411
},
412+
{
413+
"cell_type": "markdown",
414+
"id": "98a9f5f1-fb81-4c18-9631-e82df696e033",
415+
"metadata": {},
416+
"source": [
417+
"### `np.fromfile`"
418+
]
419+
},
420+
{
421+
"cell_type": "code",
422+
"execution_count": 16,
423+
"id": "5eec68f1-6fcd-4ea6-9cfa-e8b838dc4735",
424+
"metadata": {},
425+
"outputs": [
426+
{
427+
"name": "stdout",
428+
"output_type": "stream",
429+
"text": [
430+
"16.7 ms ± 1.3 ms per loop (mean ± std. dev. of 7 runs, 100 loops each)\n"
431+
]
432+
}
433+
],
434+
"source": [
435+
"%timeit np.fromfile(bin_file_name)"
436+
]
437+
},
438+
{
439+
"cell_type": "markdown",
440+
"id": "3e43e113-295c-4e68-880c-a789ff0b7d6b",
441+
"metadata": {},
442+
"source": [
443+
"Verifying the loaded data is always wise."
444+
]
445+
},
446+
{
447+
"cell_type": "code",
448+
"execution_count": 17,
449+
"id": "fb5267ba-6e37-45c7-b2e5-b64476c5c564",
450+
"metadata": {},
451+
"outputs": [
452+
{
453+
"name": "stdout",
454+
"output_type": "stream",
455+
"text": [
456+
"(10000016,) float64\n"
457+
]
458+
}
459+
],
460+
"source": [
461+
"loaded_data = np.fromfile(bin_file_name)\n",
462+
"print(loaded_data.shape, loaded_data.dtype)"
463+
]
464+
},
404465
{
405466
"cell_type": "markdown",
406467
"id": "13c58d18-7eac-4146-9e35-042db70db30e",
@@ -419,7 +480,7 @@
419480
},
420481
{
421482
"cell_type": "code",
422-
"execution_count": 16,
483+
"execution_count": 18,
423484
"id": "d1ce08c0-f7f6-4f4c-9b8f-058b19ebb20b",
424485
"metadata": {},
425486
"outputs": [],
@@ -445,7 +506,7 @@
445506
},
446507
{
447508
"cell_type": "code",
448-
"execution_count": 17,
509+
"execution_count": 19,
449510
"id": "50999bbc-a99c-4c6b-bdc8-275c4a35670e",
450511
"metadata": {},
451512
"outputs": [],
@@ -455,16 +516,16 @@
455516
},
456517
{
457518
"cell_type": "code",
458-
"execution_count": 18,
519+
"execution_count": 20,
459520
"id": "fa7576a2-d24b-4225-92ed-ceff98f58dbe",
460521
"metadata": {},
461522
"outputs": [
462523
{
463524
"name": "stdout",
464525
"output_type": "stream",
465526
"text": [
466-
"CPU times: user 5.57 ms, sys: 29.4 ms, total: 35 ms\n",
467-
"Wall time: 34.4 ms\n"
527+
"CPU times: user 24 ms, sys: 69.1 ms, total: 93.1 ms\n",
528+
"Wall time: 94.4 ms\n"
468529
]
469530
}
470531
],
@@ -477,15 +538,15 @@
477538
},
478539
{
479540
"cell_type": "code",
480-
"execution_count": 19,
541+
"execution_count": 21,
481542
"id": "ef30122b-d2a6-4ece-a56e-5f8979bd1ee2",
482543
"metadata": {},
483544
"outputs": [
484545
{
485546
"name": "stdout",
486547
"output_type": "stream",
487548
"text": [
488-
"32 ms ± 3.04 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)\n"
549+
"26.9 ms ± 308 μs per loop (mean ± std. dev. of 7 runs, 10 loops each)\n"
489550
]
490551
}
491552
],
@@ -514,7 +575,7 @@
514575
},
515576
{
516577
"cell_type": "code",
517-
"execution_count": 20,
578+
"execution_count": 22,
518579
"id": "78a90431-3976-4bb0-811f-40a49307ea0a",
519580
"metadata": {},
520581
"outputs": [
@@ -551,7 +612,7 @@
551612
},
552613
{
553614
"cell_type": "code",
554-
"execution_count": 21,
615+
"execution_count": 23,
555616
"id": "5d6b4dce-7937-4f9f-a4c9-8d74c8d117e1",
556617
"metadata": {},
557618
"outputs": [],

0 commit comments

Comments
 (0)