Re: Hygenic Macros

2005-10-19 Thread David Pokorny
Hi, Thanks - this cookbook entry is very cool! I am somewhat worried about function call overhead from the infix hack though... on second consideration, the infix issue is not as important as eventually boosting the speed of the inner loop to which matrixmultiply() belongs. For those who are

Re: Hygenic Macros

2005-10-18 Thread Dan Farina
David Pokorny wrote: Hi, Just wondering if anyone has considered macros for Python. I have one good use case. In R, the statistical programming language, you can multiply matrices with A %*% B (A*B corresponds to pointwise multiplication). In Python, I have to type import Numeric

Re: Hygenic Macros

2005-10-18 Thread Adriaan Renting
Using numarray/pylab there's also dot: from pylab import * A = array(range(10)) B = array(range(10)) A * B [ 0, 1, 4, 9,16,25,36,49,64,81,] dot(A, B) 285 It might also make your code more readable. I would like A dot B, but even using ipython I can only get as close as dot A, B Dan Farina

Re: Hygenic Macros

2005-10-18 Thread Alex Stapleton
I seem to remember a rather ugly hack at some point in the past that created a new operator like so A |dot| B where dot was an object which had the OR operator for left and right arguments redefined seperately so that it only made sense when used in that syntax. I guess you could hack

Re: Hygenic Macros

2005-10-18 Thread Alex Stapleton
Ahar got it http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/384122 Would something like that be any use? On 18 Oct 2005, at 13:21, Alex Stapleton wrote: I seem to remember a rather ugly hack at some point in the past that created a new operator like so A |dot| B where dot was an

Re: Hygenic Macros

2005-10-18 Thread Steven D'Aprano
On Mon, 17 Oct 2005 22:23:43 -0700, David Pokorny wrote: Hi, Just wondering if anyone has considered macros for Python. I have one good use case. In R, the statistical programming language, you can multiply matrices with A %*% B (A*B corresponds to pointwise multiplication). In Python,

Re: Hygenic Macros

2005-10-18 Thread Robert Kern
Steven D'Aprano wrote: On Mon, 17 Oct 2005 22:23:43 -0700, David Pokorny wrote: Hi, Just wondering if anyone has considered macros for Python. I have one good use case. In R, the statistical programming language, you can multiply matrices with A %*% B (A*B corresponds to pointwise

Re: Hygenic Macros

2005-10-18 Thread Steven D'Aprano
On Tue, 18 Oct 2005 13:42:21 -0700, Robert Kern wrote: Steven D'Aprano wrote: On Mon, 17 Oct 2005 22:23:43 -0700, David Pokorny wrote: Hi, Just wondering if anyone has considered macros for Python. I have one good use case. In R, the statistical programming language, you can multiply

Hygenic Macros

2005-10-17 Thread David Pokorny
Hi, Just wondering if anyone has considered macros for Python. I have one good use case. In R, the statistical programming language, you can multiply matrices with A %*% B (A*B corresponds to pointwise multiplication). In Python, I have to type import Numeric matrixmultiply(A,B) which makes

Re: Hygenic Macros

2005-10-17 Thread Robert Kern
David Pokorny wrote: Hi, Just wondering if anyone has considered macros for Python. I have one good use case. In R, the statistical programming language, you can multiply matrices with A %*% B (A*B corresponds to pointwise multiplication). In Python, I have to type import Numeric