function-attributes

pure/const function attributes in different compilers

pure is a function attribute which says that a function does not modify any global memory. const is a function attribute which says that a function does not read/modify any global memory. Given that information, the compiler can do some additional optimisations. Example for GCC: float sigmoid(float x) __attribute__ ((const)); float c...

using function attributes to store results for lazy (potential) processing.

I'm doing some collision detection and I would very much like to use the same function in two different contexts. In one context, I would like for it to be something like def detect_collisions(item, others): return any(collides(item, other) for other in others) and in another, I would like it to be def get_collisions(item, others...