Python execution speed

Morten W. Petersen morten at thingamy.net
Tue Nov 20 15:20:53 EST 2001


On Tue, 20 Nov 2001, Sandy Norton wrote:

> "Morten W. Petersen" <morten at thingamy.net> wrote in message
> news:Pine.LNX.4.21.0111201815190.6229-100000 at bcryachts.atsat.com...
> 
> > One of Python's advantages is a consistent (simple) design, (not counting
> > small quirks like 'def function(): return 1' and 'function =
> > lambda: 1'.  Consistent design says 'less complexity' in my ears, along
> > the same lines of the simpleness (ease of maintenance, readability,
> > portability) of a python application if it can always be coded in Python.
> 
> Excuse my curiosity but what's quirky about 'def function(): return 1' and
> 'function =
> lambda: 1'?

(I'm posting to the newsgroup as well, didn't notice you posted to
 both the newsgroup and me.)

Curiosity is good.  :-)

In Lisp, functions can be built this way:

  cl-user(3): (defun multiply (argument) (* argument argument))
  multiply
  cl-user(4): (multiply 3)
  9
  cl-user(5):

Where the last evaluated value is returned.

In Python, there is:

  def multiply(argument):
      return argument * argument

Or (using anonymous functions):

  multiply = lambda argument: argument * argument

Where the lambda has the implicit return-of-last-expression (no return
needed), while functions do not.

Helpful?

Regards,

Morten




More information about the Python-list mailing list