Python square brackets between function name and arguments: func [...] (...)

I learned to speed up python calculations on the GPU from this laptop , where one line confuses me:

mandel_kernel[griddim, blockdim](-2.0, 1.0, -1.0, 1.0, d_image, 20)

Here mandel_kernelis a decorated (through cuda.jit) function, griddimand blockdimare tuples of length 2: griddim=(32,16), blockdim=(32,8).

Are these square brackets between the function name and the argument part of the python syntax or something specific to the decoration cuda.jit?

+4
source share
1 answer

This is valid python syntax, I will try to break it for you:

mandel_kernel - dict, 2- (griddim, blockdim), - ( , python)

mandel_kernel[griddim, blockdim] '' ( )

mandel_kernel[griddim, blockdim](-2.0, 1.0, -1.0, 1.0, d_image, 20) .

:

key = tuple(griddim, blockdim)
method = mandel_kernel[key]
method(-2.0, 1.0, -1.0, 1.0, d_image, 20)
+5

Source: https://habr.com/ru/post/1654537/


All Articles