Define kwapply as a macro, define apply if python3