speeding up help.. probably deepcopy()...

Terry Reedy tjreedy at udel.edu
Tue Dec 10 11:37:59 EST 2002


"eugene kim" <eugene1977 at hotmail.com> wrote in message
news:asvtoa$i98$1 at newsreader.mailgate.org...
> http://gotofreegames.com/IQGame/free_peg_game.htm
>
> i am trying to make a program to solve the game in above page.
> It works fine.. but it's still finding solutions with 45 mins run
time.
> lol

You might find the following interesting: John D. Beasley, The Ins and
Outs of Peg Solitaire, Oxford, esp. Ch14,1st section.

> is always pass by reference in python?

If you view name binding as associating names with references to
objects, then yes.  The argument expression is evaluated, resulting in
a PyObject.  Then a reference to that object is associated with the
corresponding parameter name.  Its like a cross-namespace assignment
statement: the expression is evaluated in the calling namespace and
bound in the called namespace.

> (in java, it's always pass by value..afaik)

No, no copies in Python.  However, for immutable objects, the effect
is the same.

> It seems like scoping rules changed with new python.

Nested scopes were added in 2.1 with future import and made universal
in 2.2.  This only matters with nested functions.

Terry J. Reedy






More information about the Python-list mailing list