[Numpy-discussion] parallel loop annotations

Rahul Garg garg1 at ualberta.ca
Wed Jun 18 19:43:49 EDT 2008


Thanks for pointing them out. I will look into both of them. I like  
the "with" statement. From an implementation perspective, the "with"  
statement looks simpler since the Python parser seems to discard  
comments and I use the Python parser as front end for compiler.

For other annotations, I have been using either decorators or strings.
Decorators are used for type annotating functions. Strings just before
class declarations are currently necessary for telling the compiler
about fields of a class.

Strings can get a little ugly. Its better to use language features  
whenever possible. I will look into ipython's notation.

More comments welcome :)

thanks,
rahul


Quoting Stéfan van der Walt <stefan at sun.ac.za>:

> 2008/6/18 Rahul Garg <garg1 at ualberta.ca>:
>> I want to add a similar annotation to Python
>> example usage :
>>
>> "pragma parallel for"
>> for i in xrange(m): a[i] = b[i]*c[i]
>>
>> The interpreter ignores such strings and the code will of course
>> execute serially but such strings can potentially be used by compilers.
>> Any thoughts on this? What form of annotations would you like to see?
>> Is it pythonic?
>
> Is the idea to have the annotations completely separated from the
> executed source?  Otherwise, I'd just as well make it implicit:
>
> with parallel(i):
>     for i in range(m):
>         a[i] = b[i] * c[i]
>
> That is also roughly the form that Fernando implemented for IPython1,
> and is very intuitive.
>
> What have you been using for other annotations so far?  Python itself
> supports at least one other annotation:
>
> # encoding: utf-8
>
> so maybe
>
> # pragma: parallel for
>
> could work.
>
> Regards
> Stéfan
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion at scipy.org
> http://projects.scipy.org/mailman/listinfo/numpy-discussion
>
>





More information about the NumPy-Discussion mailing list