other:python:misc_by_jyp
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | Next revisionBoth sides next revision | ||
other:python:misc_by_jyp [2023/11/29 11:32] – [Working with paths and filenames] Improved and added pathlib example jypeter | other:python:misc_by_jyp [2023/12/08 16:36] – Added the efficient looping section jypeter | ||
---|---|---|---|
Line 313: | Line 313: | ||
[' | [' | ||
+ | |||
+ | ===== Efficient looping with numpy, map and itertools ===== | ||
+ | |||
+ | <wrap hi>Big, nested, explicit loops should be avoided at all cost</ | ||
+ | |||
+ | * **'' | ||
+ | * **Masked arrays** can be used to deal with //special cases// and remove tests from loops | ||
+ | |||
+ | * The built-in [[https:// | ||
+ | * < | ||
+ | |||
+ | >>> | ||
+ | [' | ||
+ | |||
+ | >>> | ||
+ | [' | ||
+ | |||
+ | * The [[https:// | ||
+ | * Example: replacing nested loops with [[https:// | ||
+ | * < | ||
+ | < | ||
+ | |||
+ | >>> | ||
+ | [(' | ||
+ | |||
+ | >>> | ||
+ | ... | ||
+ | ... | ||
+ | A0 | ||
+ | A1 | ||
+ | B0 | ||
+ | B1 | ||
+ | |||
+ | >>> | ||
+ | ... | ||
+ | ... | ||
+ | A0 | ||
+ | A1 | ||
+ | B0 | ||
+ | B1 | ||
+ | |||
+ | >>> | ||
+ | ... | ||
+ | ... | ||
+ | A0$, A0!, A1$, A1!, B0$, B0!, B1$, B1!,</ | ||
===== numpy related stuff ===== | ===== numpy related stuff ===== | ||
other/python/misc_by_jyp.txt · Last modified: 2024/11/04 15:01 by jypeter