Re: Quick shallow-copy idiom

2007-09-19 Thread paulhankin
On Sep 19, 10:48 am, Lawrence D'Oliveiro <[EMAIL PROTECTED]
central.gen.new_zealand> wrote:
> y = type(x)(x)

Nice trick, but is it better than the explicit:
 y = copy.copy(x)

(I think not, because copy.copy works for example, on classes
which take more than one argument to their constructor).

--
Paul Hankin

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why is this loop heavy code so slow in Python? Possible Project Euler spoilers

2007-09-19 Thread paulhankin
On Sep 2, 12:51 pm, [EMAIL PROTECTED] wrote:
> ... right-angled triangle puzzle solver
>
> max = 0
> maxIndex = 0
> index = 0
> for solution in solutions:
> if solution > max:
> max = solution
> maxIndex = index
> index += 1
>
> print maxIndex

Not that it solves your slowness problem, or has anything to
do with the question you asked :), but you can replace this
last segment of your code with:

print solutions.index(max(solutions))

--
Paul Hankin

-- 
http://mail.python.org/mailman/listinfo/python-list