[PEAK] Re: Generic functions in Python
Phillip J. Eby
pje at telecommunity.com
Thu Feb 7 16:59:59 EST 2008
At 03:33 PM 2/7/2008 -0600, Aaron Lebo wrote:
>I really was wanting to use generic functions in Python, but I'm
>unsure which library is the best to use. There is RuleDispatch and
>then also PEAK-Rules (?). Which would you suggest using? I'm looking
>to use something with similar power to Common Lisp generic
>functions, will either library fit that requirement?
Both exceed Common Lisp's power, as CL doesn't do predicate dispatch
(or even symmetric multi-dispatch). They don't include all of the CL
method combinations, but in either case you can write any method
combination you need with a bit of work.
>Also, are there performance/portability issues I should be aware of
>(does this or can this run on Jython/IronPython in the future)?
RuleDispatch is capable of operating in a pure-Python mode and IIRC
does not rely on any hacks that wouldn't be (in principle) portable
to Jython or IronPython. RuleDispatch, however, isn't going to be
supported in the future, except perhaps as a compatibility API around
PEAK-Rules is 100% pure Python, but isn't as portable since the
engine system relies on CPython bytecode manipulation. It'd be quite
possible, however, to make it more portable, e.g. by adding engines
that do source code generation, CLR/JVM bytecode generation,
etc. But at the moment I don't have any plans to do that.
>Finally, I was looking around for docs, do those come with the source?
RuleDispatch doesn't really have any, except for a couple of Wiki
pages. PEAK-Rules has massive amounts of internal documentation as
.txt files with the source, but doesn't have any beginning user docs
at the moment.
>Sorry for all the questions! Thanks for your help and all the work
In future, please send all emails regarding my open source software
to the PEAK mailing list or distutils-SIG (for setuptools).
More information about the PEAK