the Swamp of Sluggish Iterations for several hours...

and I'll be your game master today.

the Swamp of Sluggish Iterations.

said the paladin,

says the mage,

That might be your way out of this stinky swamp.

to match the dimensions of two arrays.

(Scalars are just zero-dimension arrays.)

Vectors are of dimension 1.

We can switch from row vectors to column vectors

using np.newaxis.

Or None.

np.transpose or .T do the trick (no copy is needed).

in a data-driven way.

Let's compute the weighted attributes for each member of the group."

Here is the full data."

to index NumPy arrays.

Can we select loot values between 5 and 30?

What are the difficulty values of dungeons 1, 4 and 7

for floors 0, 2 and 3?

Where can I find object 8?

Which objects are available in the range 10 to 20?

From a detailed table, can I get how many pieces each one got in last floors of dungeons?

We want to compute the contribution of each attribute point to the loot.

You can also use Einstein notation.

However, the measurements are noisy!"

We want to compute the windowed average on 5 measurements.

Strides are virtual views on your array

that add virtual dimensions without
copying anything.

They are tricky to use

but can give huge performance boosts.

Universal functions are vectorized functions that operates on arrays element-wise."

NumPy comes with a whole lot of unary and binary ufuncs (add, multiply, exponential, trigonometric functions, arithmetic operations, comparisons).

They support broadcasting,

reduce and accumulate operations.

What about more exotic ufuncs?

We'll need to compute an awful lot of distances"

Remember the running average we computed earlier?

Numba can help with that too!

comes to its end,

hereby lies

what you should remember!"

For best performance, get out of Python as quickly as possible, and do not go back till the end.

Embrace the world of NumPy fully!

Almost everything you want to do

probably already has an implementation...

in NumPy, in SciPy or in scikit-learn.

Use it, it'll always be faster (and not bugged)!

When in difficulty, Numba will help you.

At least, it's worth a try.

Thank you for participating

in this adventure!

sarah.diot-girard@people-doc.com

We're hiring !

And we have a RPG club!

Characters illustrations from here .