Elementwise -//- first release -//- Element-wise (vectorized) function, method and operator support for iterables in python.
Paul Dubois
pfdubois at gmail.com
Wed Dec 21 12:07:28 EST 2011
You're reinventing Numeric Python.
On Tue, Dec 20, 2011 at 11:45 AM, Nathan Rice <
nathan.alexander.rice at gmail.com> wrote:
> Elementwise provides a proxy object for iterables which supports
> chained method calls, as well as elementwise expressions and some
> built-in functions.
>
> Example:
>
> class ExampleList(ElementwiseProxyMixin, list):
> def __new__(cls, iterable):
> return list.__new__(cls, iterable)
> foo = ExampleList([1, 2, 3, 4])
>
> # You could also do: efoo = ElementwiseProxy(foo)
> efoo = foo.each
>
> assert list(efoo.bit_length()) == [1, 2, 2, 3]
> print "bit length: ", list(efoo.bit_length())
> assert list(efoo + 1) == [2, 3, 4, 5]
> print "with addition of 1: ", list(efoo + 1)
> assert list(efoo * 2) == [2, 4, 6, 8]
> print "with multiplication by 2: ", list(efoo * 2)
> assert list(efoo == 2) == [False, True, False, False]
> print "testing equality: ", efoo == 2
> assert list((efoo + 1) * 2 + 3) == [7, 9, 11, 13]
> print "chaining addition and multiplication: ", (efoo + 1) * 2 + 3
>
> Each ElementwiseProxy also has a "parent" attribute so you can
> backtrack in the chain as needed rather than store each intermediate
> value, if you think you might need them.
>
> There are still some issues with proper support of things like bool()
> and int(), which refuse to return things that are not of the correct
> type.
>
> Get it:
>
> PyPi: http://pypi.python.org/pypi/elementwise/0.111220
> GitHub: https://github.com/nathan-rice/Elementwise
>
> This was developed as a proof of concept for expanding the role of
> element-wise syntax in python, and to that end I welcome comments.
>
> Nathan Rice
> --
> http://mail.python.org/mailman/listinfo/python-announce-list
>
> Support the Python Software Foundation:
> http://www.python.org/psf/donations/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20111221/b2232df9/attachment-0001.html>
More information about the Python-list
mailing list