[ANN] functional 0.5 released

C

Collin Winter

Hello all,

I have released version 0.5 of my functional module, a collection of
higher-order and functional programming tools for Python. Currently
offered are tools for function composition, partial function
application, plus flip, foldl, foldr, scanl and scanr functions.

Two version of the release are available: one is written in pure
Python and aims for maximum readability and portability. The other is
coded as a C extension module and is focused on raw performance.

Where to get it:
#########

functional is available at

http://oakwinter.com/code/functional/

and from the Python Package Index at

http://cheeseshop.python.org/pypi/functional.

Both source tarballs and Python Eggs are available for both the pure
Python and C releases. I'm open to user-contributed RPM, Deb or other
packagings.

Release Notes
########

The biggest news in this release is the addition of the C
implementation. Also, a number of functions were removed, as I had
unknowingly duplicated a lot of functionality from the itertools
module.

As always, feedback welcome!

Collin Winter
 
B

bonono

Collin said:
As always, feedback welcome!

Any specific reason flip only flip the first 2 arguments rather than
the whole tuple ?

That is, I would like to see:

assert(f(a,b,c, d) == flip(f)(d, c, b, a))
 
C

Collin Winter

Any specific reason flip only flip the first 2 arguments rather than
the whole tuple ?

That is, I would like to see:

assert(f(a,b,c, d) == flip(f)(d, c, b, a))

Because that's what I'm used to from Haskell and other functional
languages : ) I'll see what I can do about having it flip all
arguments in the next release.

Thanks,
Collin Winter
 
B

bonono

Collin said:
Because that's what I'm used to from Haskell and other functional
languages : ) I'll see what I can do about having it flip all
arguments in the next release.
Thanks for looking into it.

BTW, I do a quick test on the C version(supposed to be faster) and
found something interesting:

Your partial implementation is slower than new.instancemethod(func,
arg, object), may be you would like to have some micro optimization to
use that instead for the special case(and I believe over 70% of the
case) of :

partial(func, arg)

Another thing I am wondering is if a compose_m(which means
f(*g(*arg,**kw)) ) is desirable as that would give me a choice if I
want to expand the result of g(if it is a tuple) to multi-argument
rather than single tuple. This is not a problem in Haskell which is
fully curried but python in general is not. Another option may be a
helper function like unpack in lua. So I can do compose(compose(f,
unpack), g) which means f(unpack(g(*arg,**kw))).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,994
Messages
2,570,222
Members
46,810
Latest member
Kassie0918

Latest Threads

Top