Rocksolid Light

News from da outaworlds

mail  files  register  groups  login

Message-ID:  

BOFH excuse #293: You must've hit the wrong any key.


comp / comp.lang.python / Re: Beazley's Problem

SubjectAuthor
* Beazley's ProblemStefan Ram
`* Re: Beazley's ProblemPaul Rubin
 `* Re: Beazley's ProblemStefan Ram
  `* Re: Beazley's ProblemPaul Rubin
   `* Re: Beazley's ProblemAnnada Behera
    +* Re: Beazley's ProblemStefan Ram
    |+- Re: Beazley's Problem (Posting On Python-List Prohibited)Lawrence D'Oliveiro
    |+* Re: Beazley's ProblemPaul Rubin
    ||+- Re: Beazley's ProblemAnnada Behera
    ||`* Re: Beazley's Problemdavid k. combs
    || `- Re: Beazley's ProblemPaul Rubin
    |`* Modern Optimization (was: Beazley's Problem)Stefan Ram
    | +- Re: Modern OptimizationStefan Ram
    | `- Re: Modern Optimization (was: Beazley's Problem)Gilmeh Serda
    `- Re: Beazley's ProblemAntoon Pardon

1
Subject: Beazley's Problem
From: Stefan Ram
Newsgroups: comp.lang.python
Organization: Stefan Ram
Date: Sat, 21 Sep 2024 12:15 UTC
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!fu-berlin.de!uni-berlin.de!not-for-mail
From: ram@zedat.fu-berlin.de (Stefan Ram)
Newsgroups: comp.lang.python
Subject: Beazley's Problem
Date: 21 Sep 2024 12:15:37 GMT
Organization: Stefan Ram
Lines: 97
Expires: 1 Jul 2025 11:59:58 GMT
Message-ID: <problem-20240921130726@ram.dialup.fu-berlin.de>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: news.uni-berlin.de G5ibqQulTZUbdOIIVFzXfAWDdpYAb1SN6qQ7Cui87sURIJ
Cancel-Lock: sha1:zQ4DmC+etEE3BiCKWoKJCP9W960= sha256:ZJ9ZPaYUQfRcuHSnyV8xoL44pJ/jUZgvnmX7G1AxwMw=
X-Copyright: (C) Copyright 2024 Stefan Ram. All rights reserved.
Distribution through any means other than regular usenet
channels is forbidden. It is forbidden to publish this
article in the Web, to change URIs of this article into links,
and to transfer the body without this notice, but quotations
of parts in other Usenet posts are allowed.
X-No-Archive: Yes
Archive: no
X-No-Archive-Readme: "X-No-Archive" is set, because this prevents some
services to mirror the article in the web. But the article may
be kept on a Usenet archive server with only NNTP access.
X-No-Html: yes
Content-Language: en-US
View all headers

I recently caught this vid "The Problem with The Problem"
featuring David Beazley. In it, he dropped this problem
that went something like:

|Picture this: there's a guy who owns a movie theater in Santa Monica,
|and he's got the freedom to set ticket prices however he wants.
| |But here's the catch: the higher he sets the price, the fewer
|people show up. So, he recently did a little experiment to
|figure out exactly how ticket prices affect attendance.
| |Turns out, when he charges $5.00 per ticket, about 120 folks
|come to watch a movie. (=1)
| |But if he knocks the price down by just 10 cents, an extra 15
|people show up. (=2)
| |Now, here's where it gets tricky. More people means more
|costs. Running each show sets him back $180, and every person
|who walks through the door adds another four cents to his
|expenses. (=3)
| |What he's trying to figure out is how all these numbers play
|together so he can set the perfect ticket price that brings in
|the most cash.

David basically said, "The owner wants to find out how to maximize
his profit."

He didn't spell out the exact task, but mentioned he throws
this curveball in some of his courses. And I'm betting my
bottom dollar they're Python programming classes!

So I hit pause on the video and thought to myself: "How would I
tackle coding this bad boy?"

Before you keep reading, why don't you take a crack at it yourself?

Alright, so here's how I approached it: We know that when the
price x is 5 bucks, the number of people n is 120 (^1).

n( 5 )= 120

We know that for every i times 0.1 dollar price hike, (-i)*15 more
people n show up (^2).

n( x + 0.1*i )= n( x )- 15*i

The overhead c for an event is 180 smackers plus 0.04 bucks per
head (^3).

c = 180 + n*0.04

So the profit p for an event with n people, each shelling out
x dollars, comes out to turnover minus costs:

p( x )= n( x )*x - c.

A change in attendance that's exactly proportional to the
price means the number of people depends on the price in an
affine-linear way. By plugging in the two known relationships
"n( 5 )= 120" and "n( x + 0.1*i )= n( x )- 15*i", we can
nail down the coefficients of the affine-linear function:

n( x )= 870 - 150*x.

The profit "n( x )*x - c" then becomes

p( x )= n( x )*x - c
= -150*x*x +( 870 + 150*0.04 )x - 180 - 870*0.04.

The derivative of the profit with respect to price x is

p'( x )= -2*150*x +( 870 + 150*0.04 ).

By setting the derivative to zero, you find the maximum at

x = 87/30 + 0.02

if my math isn't off the rails!

So, my approach to this programming challenge would be to
say that it's best to determine the maximum analytically,
and then the Python program boils down to:

print( "The maximum profit is at" )
print( 87/30 + 0.02 )
print( "viewers." )

Or you could install one of those fancy symbolic math libraries
for Python and let it handle all the manual transformations
I just walked through.

Now I'm on pins and needles to see where David Beazley's talk
goes from here!

Subject: Re: Beazley's Problem
From: Paul Rubin
Newsgroups: comp.lang.python
Organization: A noiseless patient Spider
Date: Sat, 21 Sep 2024 12:45 UTC
References: 1
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: no.email@nospam.invalid (Paul Rubin)
Newsgroups: comp.lang.python
Subject: Re: Beazley's Problem
Date: Sat, 21 Sep 2024 05:45:59 -0700
Organization: A noiseless patient Spider
Lines: 24
Message-ID: <87tte941ko.fsf@nightsong.com>
References: <problem-20240921130726@ram.dialup.fu-berlin.de>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Date: Sat, 21 Sep 2024 14:46:00 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="e94199ffdbd21758a00d3c67b53911fe";
logging-data="1689580"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+J8h+JXY4Y59/SVt5tfXfP"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)
Cancel-Lock: sha1:YxZq7BtGtX0Gsb569loqP5XlhOs=
sha1:mbH4Etd7anjlh+h/bK0goxc90OQ=
View all headers

ram@zedat.fu-berlin.de (Stefan Ram) writes:
> Alright, so here's how I approached it: We know that when the
> price x is 5 bucks, the number of people n is 120 (^1).

That assumption doesn't seem so good, but accepting it, your answer
looks right. Here is a pure numerical solution. Since the profit
function is quadratic, the Newton iteration converges immediately.
================================================================
def cost(n): return 180+.04*n # cost to show to n viewers
def revenue(price,n): return price*n # amount collected from them
def people(price): return 120.+(price-5)*(-15./.1) # number who will attend
def profit(price):
n = people(price)
return revenue(price,n) - cost(n)

def ddx(f,x,h=0.001): return (f(x+h)-f(x-h))/(2*h) # numerical derivative
def newton(f,x0): return x0 - f(x0)/ddx(f,x0) # Newton-Raphson iteration

def dprofit(price): return ddx(profit, price) # derivative of profit

x = 5.
for i in range(3):
print(f'{i} {x:.4f} {profit(x):.1f} {dprofit(x):.1f}')
x = newton(dprofit,x)

Subject: Re: Beazley's Problem
From: Stefan Ram
Newsgroups: comp.lang.python
Organization: Stefan Ram
Date: Sat, 21 Sep 2024 14:18 UTC
References: 1 2
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!fu-berlin.de!uni-berlin.de!not-for-mail
From: ram@zedat.fu-berlin.de (Stefan Ram)
Newsgroups: comp.lang.python
Subject: Re: Beazley's Problem
Date: 21 Sep 2024 14:18:07 GMT
Organization: Stefan Ram
Lines: 8
Expires: 1 Jul 2025 11:59:58 GMT
Message-ID: <newton-20240921151727@ram.dialup.fu-berlin.de>
References: <problem-20240921130726@ram.dialup.fu-berlin.de> <87tte941ko.fsf@nightsong.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: news.uni-berlin.de 4rTPyldfPqZz+oTTP2mQ9gEMoZMVZbiq1yiu3lcLd2/rcw
Cancel-Lock: sha1:8Ug6AdJFZziZ8IpkwDTVwKuf+As= sha256:yH8Kc0U2+QSOvLgAho02Vai+WjSXp1b1ozYdpXYriow=
X-Copyright: (C) Copyright 2024 Stefan Ram. All rights reserved.
Distribution through any means other than regular usenet
channels is forbidden. It is forbidden to publish this
article in the Web, to change URIs of this article into links,
and to transfer the body without this notice, but quotations
of parts in other Usenet posts are allowed.
X-No-Archive: Yes
Archive: no
X-No-Archive-Readme: "X-No-Archive" is set, because this prevents some
services to mirror the article in the web. But the article may
be kept on a Usenet archive server with only NNTP access.
X-No-Html: yes
Content-Language: en-US
View all headers

Paul Rubin <no.email@nospam.invalid> wrote or quoted:
>def ddx(f,x,h=0.001): return (f(x+h)-f(x-h))/(2*h) # numerical derivative
>def newton(f,x0): return x0 - f(x0)/ddx(f,x0) # Newton-Raphson iteration

It's hella rad to see you bust out those "next-level math tricks"
with just a single line each!

Subject: Re: Beazley's Problem
From: Paul Rubin
Newsgroups: comp.lang.python
Organization: A noiseless patient Spider
Date: Sat, 21 Sep 2024 20:19 UTC
References: 1 2 3
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: no.email@nospam.invalid (Paul Rubin)
Newsgroups: comp.lang.python
Subject: Re: Beazley's Problem
Date: Sat, 21 Sep 2024 13:19:50 -0700
Organization: A noiseless patient Spider
Lines: 9
Message-ID: <87plow4v4p.fsf@nightsong.com>
References: <problem-20240921130726@ram.dialup.fu-berlin.de>
<87tte941ko.fsf@nightsong.com>
<newton-20240921151727@ram.dialup.fu-berlin.de>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Date: Sat, 21 Sep 2024 22:19:50 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="e94199ffdbd21758a00d3c67b53911fe";
logging-data="1822989"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19RaUfw8GYplCQqYtuMJIYX"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)
Cancel-Lock: sha1:3o3wtfp3CWvf9YmY/Q0tAv31n9E=
sha1:SuTy/J0zag5cTi2KkbaNIRj3mBg=
View all headers

ram@zedat.fu-berlin.de (Stefan Ram) writes:
> It's hella rad to see you bust out those "next-level math tricks"
> with just a single line each!

You might like:

https://www.cs.kent.ac.uk/people/staff/dat/miranda/whyfp90.pdf

The numerics stuff starts on page 9.

Subject: Re: Beazley's Problem
From: Annada Behera
Newsgroups: comp.lang.python
Organization: tilde.green
Date: Mon, 23 Sep 2024 07:44 UTC
References: 1 2 3 4
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!news.quux.org!tilde.green!.POSTED.103.160.128.32!not-for-mail
From: annada@tilde.green (Annada Behera)
Newsgroups: comp.lang.python
Subject: Re: Beazley's Problem
Date: Mon, 23 Sep 2024 13:14:00 +0530
Organization: tilde.green
Sender: annada@tilde.green
Message-ID: <0709b4b8b0bbf2a32d53649d1a6fbefbcd44a68a.camel@tilde.green>
References: <problem-20240921130726@ram.dialup.fu-berlin.de>
<87tte941ko.fsf@nightsong.com>
<newton-20240921151727@ram.dialup.fu-berlin.de>
<87plow4v4p.fsf@nightsong.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Injection-Info: tilde.green; posting-account="annada@tilde.green"; posting-host="103.160.128.32";
logging-data="3333592"; mail-complaints-to="admins@tilde.green"
User-Agent: Evolution 3.52.2
In-Reply-To: <87plow4v4p.fsf@nightsong.com>
View all headers

The "next-level math trick" Newton-Raphson has nothing to do with
functional programming. I have written solvers in purely iterative
style. As far as I know, Newton-Raphson is the opposite of functional
programming as you iteratively solve for the root. Functional programming
is stateless where you are not allowed to store any state (current best
guess root).

-----Original Message-----
From: Paul Rubin <no.email@nospam.invalid>
Subject: Re: Beazley's Problem
Date: 09/22/2024 01:49:50 AM
Newsgroups: comp.lang.python

ram@zedat.fu-berlin.de (Stefan Ram) writes:
>   It's hella rad to see you bust out those "next-level math tricks"
>   with just a single line each!

You might like:

https://www.cs.kent.ac.uk/people/staff/dat/miranda/whyfp90.pdf

The numerics stuff starts on page 9.

Subject: Re: Beazley's Problem
From: Stefan Ram
Newsgroups: comp.lang.python
Organization: Stefan Ram
Date: Mon, 23 Sep 2024 12:26 UTC
References: 1 2 3 4 5
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!fu-berlin.de!uni-berlin.de!not-for-mail
From: ram@zedat.fu-berlin.de (Stefan Ram)
Newsgroups: comp.lang.python
Subject: Re: Beazley's Problem
Date: 23 Sep 2024 12:26:38 GMT
Organization: Stefan Ram
Lines: 49
Expires: 1 Jul 2025 11:59:58 GMT
Message-ID: <Newton-20240923132243@ram.dialup.fu-berlin.de>
References: <problem-20240921130726@ram.dialup.fu-berlin.de> <87tte941ko.fsf@nightsong.com> <newton-20240921151727@ram.dialup.fu-berlin.de> <87plow4v4p.fsf@nightsong.com> <0709b4b8b0bbf2a32d53649d1a6fbefbcd44a68a.camel@tilde.green>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: news.uni-berlin.de MhHMeHGEDJkkKr5yvniG1QcRef70q1EE5Su4TETfrBCOU4
Cancel-Lock: sha1:BPjQO8/eZGVm9mcMLYynUOUMiOc= sha256:P556lyQSH0RBiw+SpaOU+o0cJaEhmwam977NgDQd/f8=
X-Copyright: (C) Copyright 2024 Stefan Ram. All rights reserved.
Distribution through any means other than regular usenet
channels is forbidden. It is forbidden to publish this
article in the Web, to change URIs of this article into links,
and to transfer the body without this notice, but quotations
of parts in other Usenet posts are allowed.
X-No-Archive: Yes
Archive: no
X-No-Archive-Readme: "X-No-Archive" is set, because this prevents some
services to mirror the article in the web. But the article may
be kept on a Usenet archive server with only NNTP access.
X-No-Html: yes
Content-Language: en-US
View all headers

Annada Behera <annada@tilde.green> wrote or quoted:
>The "next-level math trick" Newton-Raphson has nothing to do with
>functional programming.

Nobody up the thread was claiming it was functional. And you can
totally implement anything in an imperative or functional style.

from typing import Callable

def newton_raphson(
f: Callable[[float], float],
f_prime: Callable[[float], float],
x0: float,
epsilon: float = 1e-7,
max_iterations: int = 100
) -> float:
def recurse(x: float, iteration: int) -> float:
if iteration > max_iterations:
raise ValueError("Maximum iterations reached. The method may not converge.")

fx: float = f(x)
if abs(fx) < epsilon:
return x

x_next: float = x - fx / f_prime(x)
return recurse(x_next, iteration + 1)

return recurse(x0, 0)

# Example application: find a root of f(x) = x^2 - 4

# Define the function and its derivative
def f(x: float) -> float:
return x**2 - 4

def f_prime(x: float) -> float:
return 2*x

# Initial guess
x0: float = 1.0

try:
root: float = newton_raphson(f, f_prime, x0)
print(f"The root is approximately: {root}")
print(f"f({root}) = {f(root)}")
except ValueError as e:
print(f"Error: {e}")

Subject: Re: Beazley's Problem (Posting On Python-List Prohibited)
From: Lawrence D'Oliv
Newsgroups: comp.lang.python
Organization: A noiseless patient Spider
Date: Mon, 23 Sep 2024 22:44 UTC
References: 1 2 3 4 5 6
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ldo@nz.invalid (Lawrence D'Oliveiro)
Newsgroups: comp.lang.python
Subject: Re: Beazley's Problem (Posting On Python-List Prohibited)
Date: Mon, 23 Sep 2024 22:44:11 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 8
Message-ID: <vcsqvq$2spdj$2@dont-email.me>
References: <problem-20240921130726@ram.dialup.fu-berlin.de>
<87tte941ko.fsf@nightsong.com>
<newton-20240921151727@ram.dialup.fu-berlin.de>
<87plow4v4p.fsf@nightsong.com>
<0709b4b8b0bbf2a32d53649d1a6fbefbcd44a68a.camel@tilde.green>
<Newton-20240923132243@ram.dialup.fu-berlin.de>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 24 Sep 2024 00:44:11 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="43fa132f54fd9f5c91573130fd9389bf";
logging-data="3040691"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/vZ13mMzwiIM8f7cR4M9EZ"
User-Agent: Pan/0.160 (Toresk; )
Cancel-Lock: sha1:39wJmWrdqWLlzFuM1PvQPHYTrAI=
View all headers

On 23 Sep 2024 12:26:38 GMT, Stefan Ram wrote:

> And you can totally implement anything in an imperative or functional
> style.

Except for I/O, which does not fit a pure-functional programming style.
Even “pure-functional” languages have to sacrifice the “pure” part when it
comes to I/O.

Subject: Re: Beazley's Problem
From: Paul Rubin
Newsgroups: comp.lang.python
Organization: A noiseless patient Spider
Date: Tue, 24 Sep 2024 00:22 UTC
References: 1 2 3 4 5 6
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: no.email@nospam.invalid (Paul Rubin)
Newsgroups: comp.lang.python
Subject: Re: Beazley's Problem
Date: Mon, 23 Sep 2024 17:22:27 -0700
Organization: A noiseless patient Spider
Lines: 14
Message-ID: <87h6a5lx30.fsf@nightsong.com>
References: <problem-20240921130726@ram.dialup.fu-berlin.de>
<87tte941ko.fsf@nightsong.com>
<newton-20240921151727@ram.dialup.fu-berlin.de>
<87plow4v4p.fsf@nightsong.com>
<0709b4b8b0bbf2a32d53649d1a6fbefbcd44a68a.camel@tilde.green>
<Newton-20240923132243@ram.dialup.fu-berlin.de>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Date: Tue, 24 Sep 2024 02:22:28 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="5802c01959a5df245c2a5a0646fadea0";
logging-data="3064986"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19bD/Ky6qZrHVN2Kt4SksBK"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)
Cancel-Lock: sha1:+W6NnIryRoYgTJTkWNoi+hVsfY0=
sha1:n+Dy/xANJ0jmSmmHT0mXvHr1hG4=
View all headers

ram@zedat.fu-berlin.de (Stefan Ram) writes:
> Nobody up the thread was claiming it was functional. And you can
> totally implement anything in an imperative or functional style.

Yeah the confusion was because I posted a link to "Why FP Matters",
which discusses these sorts of numerical hacks.

> def f_prime(x: float) -> float:
> return 2*x

You might enjoy implementing that with automatic differentiation (not to
be confused with symbolic differentiation) instead.

http://blog.sigfpe.com/2005/07/automatic-differentiation.html

Subject: Re: Beazley's Problem
From: Annada Behera
Newsgroups: comp.lang.python
Organization: tilde.green
Date: Tue, 24 Sep 2024 08:25 UTC
References: 1 2 3 4 5 6 7
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!news.quux.org!tilde.green!.POSTED.103.160.128.32!not-for-mail
From: annada@tilde.green (Annada Behera)
Newsgroups: comp.lang.python
Subject: Re: Beazley's Problem
Date: Tue, 24 Sep 2024 13:55:57 +0530
Organization: tilde.green
Sender: annada@tilde.green
Message-ID: <08bddb548dce214b1d41432e92d431d0ef304929.camel@tilde.green>
References: <problem-20240921130726@ram.dialup.fu-berlin.de>
<87tte941ko.fsf@nightsong.com>
<newton-20240921151727@ram.dialup.fu-berlin.de>
<87plow4v4p.fsf@nightsong.com>
<0709b4b8b0bbf2a32d53649d1a6fbefbcd44a68a.camel@tilde.green>
<Newton-20240923132243@ram.dialup.fu-berlin.de>
<87h6a5lx30.fsf@nightsong.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Injection-Info: tilde.green; posting-account="annada@tilde.green"; posting-host="103.160.128.32";
logging-data="945769"; mail-complaints-to="admins@tilde.green"
User-Agent: Evolution 3.52.2
In-Reply-To: <87h6a5lx30.fsf@nightsong.com>
View all headers

-----Original Message-----
From: Paul Rubin <no.email@nospam.invalid>
Subject: Re: Beazley's Problem
Date: 09/24/2024 05:52:27 AM
Newsgroups: comp.lang.python

>> def f_prime(x: float) -> float:
>>     return 2*x
>
>You might enjoy implementing that with automatic differentiation (not
>to be confused with symbolic differentiation) instead.
>
>http://blog.sigfpe.com/2005/07/automatic-differentiation.html

Before I knew automatic differentiation, I thought neural networks
backpropagation was magic. Although coding up backward mode autodiff is
little trickier than forward mode autodiff.

(a) Forward-mode autodiff takes less space (just a dual component of
every input variable) but needs more time to compute. For any function:
f:R->R^m, forward mode can compute the derivates in O(m^0)=O(1) time,
but O(m) time for f:R^m->R.

(b) Reverse-mode autodiff requires you build a computation graph which
takes space but is faster. For function: f:R^m->R, they can run in
O(m^0)=O(1) time and vice versa ( O(m) time for f:R->R^m ).

Almost all neural network training these days use reverse-mode autodiff.

Subject: Modern Optimization (was: Beazley's Problem)
From: Stefan Ram
Newsgroups: comp.lang.python
Organization: Stefan Ram
Date: Thu, 26 Sep 2024 12:51 UTC
References: 1 2 3 4 5 6
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!fu-berlin.de!uni-berlin.de!not-for-mail
From: ram@zedat.fu-berlin.de (Stefan Ram)
Newsgroups: comp.lang.python
Subject: Modern Optimization (was: Beazley's Problem)
Date: 26 Sep 2024 12:51:13 GMT
Organization: Stefan Ram
Lines: 52
Expires: 1 Jul 2025 11:59:58 GMT
Message-ID: <optimizations-20240926134921@ram.dialup.fu-berlin.de>
References: <problem-20240921130726@ram.dialup.fu-berlin.de> <87tte941ko.fsf@nightsong.com> <newton-20240921151727@ram.dialup.fu-berlin.de> <87plow4v4p.fsf@nightsong.com> <0709b4b8b0bbf2a32d53649d1a6fbefbcd44a68a.camel@tilde.green> <Newton-20240923132243@ram.dialup.fu-berlin.de>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: news.uni-berlin.de gVEjUUA4jt9uTbwrbofZHwVRVoPfFdysO5CdIDPr3CTuCw
Cancel-Lock: sha1:4hhSsxGrl8NrlXRO/sZgrzVzvWo= sha256:qjnScNwl8PQhdq08Xi7kGRaQXBNDuBOZNnezb2FySr8=
X-Copyright: (C) Copyright 2024 Stefan Ram. All rights reserved.
Distribution through any means other than regular usenet
channels is forbidden. It is forbidden to publish this
article in the Web, to change URIs of this article into links,
and to transfer the body without this notice, but quotations
of parts in other Usenet posts are allowed.
X-No-Archive: Yes
Archive: no
X-No-Archive-Readme: "X-No-Archive" is set, because this prevents some
services to mirror the article in the web. But the article may
be kept on a Usenet archive server with only NNTP access.
X-No-Html: yes
Content-Language: en-US
View all headers

ram@zedat.fu-berlin.de (Stefan Ram) wrote or quoted:
>totally implement anything in an imperative or functional style.

In functional programming, you don't redefine names. So,

|let i := 7

is still kosher with functional programming, while

|let i := 7
|let i := 8

is a no-go. Why am I bringing this up?

If you redefine a name in a Python module (since around 2022), like,

|i = 7
.. . .
|i = 8

, you're putting the kibosh on a certain optimization for name lookup
and your program's going to drag. This means that sprinkling in a little
functional programming mojo can make your Python programs zip along!

This was laid out by Kevin Modzelewski in a talk back in 2022.

He dropped these nuggets for Python programs (for CPython, I take it)
that don't cramp modern optimizations:

- Don't reassign global variables.

- All objects of a class should have the same attributes
(names, not values; i.e., "obj.dict.keys()" shouldn't
be different between objects of the same class).

- Set the same attributes in the same order for all objects
of a class.

- Use slots.

- Don't change attributes of classes of objects.

- Don't bother trying to optimize attribute lookup for
method calls outside of loops anymore.
(Don't try to "cache" methods in variables.)
The optimizer will take care of this today better
than you could ever do.

What else puts the brakes on a program is using module "getattr"
methods and tracing or profiling.

Subject: Re: Modern Optimization
From: Stefan Ram
Newsgroups: comp.lang.python
Organization: Stefan Ram
Date: Thu, 26 Sep 2024 12:54 UTC
References: 1 2 3 4 5 6 7
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!fu-berlin.de!uni-berlin.de!not-for-mail
From: ram@zedat.fu-berlin.de (Stefan Ram)
Newsgroups: comp.lang.python
Subject: Re: Modern Optimization
Date: 26 Sep 2024 12:54:34 GMT
Organization: Stefan Ram
Lines: 6
Expires: 1 Jul 2025 11:59:58 GMT
Message-ID: <dict-20240926135416@ram.dialup.fu-berlin.de>
References: <problem-20240921130726@ram.dialup.fu-berlin.de> <87tte941ko.fsf@nightsong.com> <newton-20240921151727@ram.dialup.fu-berlin.de> <87plow4v4p.fsf@nightsong.com> <0709b4b8b0bbf2a32d53649d1a6fbefbcd44a68a.camel@tilde.green> <Newton-20240923132243@ram.dialup.fu-berlin.de> <optimizations-20240926134921@ram.dialup.fu-berlin.de>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: news.uni-berlin.de TJ02VlEg7Sf85LGgH4PU2gXtvzk6r0y8XZ6vCvjO7sHwMz
Cancel-Lock: sha1:bdEzblGemn4AUukAg3jemmwJDqg= sha256:pcPrVbvive3rB6hajFnbQxR9SVFK2S6XuO5ra+iUTaw=
X-Copyright: (C) Copyright 2024 Stefan Ram. All rights reserved.
Distribution through any means other than regular usenet
channels is forbidden. It is forbidden to publish this
article in the Web, to change URIs of this article into links,
and to transfer the body without this notice, but quotations
of parts in other Usenet posts are allowed.
X-No-Archive: Yes
Archive: no
X-No-Archive-Readme: "X-No-Archive" is set, because this prevents some
services to mirror the article in the web. But the article may
be kept on a Usenet archive server with only NNTP access.
X-No-Html: yes
Content-Language: en-US
View all headers

ram@zedat.fu-berlin.de (Stefan Ram) wrote or quoted:
>(names, not values; i.e., "obj.dict.keys()" shouldn't

obj.__dict__.keys()

Subject: Re: Modern Optimization (was: Beazley's Problem)
From: Gilmeh Serda
Newsgroups: comp.lang.python
Organization: Easynews - www.easynews.com
Date: Thu, 26 Sep 2024 16:13 UTC
References: 1 2 3 4 5 6 7
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!news.szaf.org!3.eu.feeder.erje.net!feeder.erje.net!feeder1.feed.ams11.usenet.farm!feed.usenet.farm!peer02.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!fx10.ams4.POSTED!not-for-mail
From: gilmeh.serda@nothing.here.invalid (Gilmeh Serda)
Subject: Re: Modern Optimization (was: Beazley's Problem)
Newsgroups: comp.lang.python
References: <problem-20240921130726@ram.dialup.fu-berlin.de>
<87tte941ko.fsf@nightsong.com>
<newton-20240921151727@ram.dialup.fu-berlin.de>
<87plow4v4p.fsf@nightsong.com>
<0709b4b8b0bbf2a32d53649d1a6fbefbcd44a68a.camel@tilde.green>
<Newton-20240923132243@ram.dialup.fu-berlin.de>
<optimizations-20240926134921@ram.dialup.fu-berlin.de>
MIME-Version: 1.0
x-no-archive: yes
User-Agent: Pan/0.160 (Toresk; 9d04e24)
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Lines: 11
Message-ID: <7LfJO.211782$XGr1.85544@fx10.ams4>
X-Complaints-To: abuse@easynews.com
Organization: Easynews - www.easynews.com
X-Complaints-Info: Please be sure to forward a copy of ALL headers otherwise we will be unable to process your complaint properly.
Date: Thu, 26 Sep 2024 16:13:55 GMT
X-Received-Bytes: 1222
View all headers

On 26 Sep 2024 12:51:13 GMT, Stefan Ram wrote:

> - Use slots.

....or you end up with sloths? ;)

--
Gilmeh

Why, every one as they like; as the good woman said when she kissed her
cow. -- Rabelais

Subject: Re: Beazley's Problem
From: Antoon Pardon
Newsgroups: comp.lang.python
Date: Sun, 6 Oct 2024 20:19 UTC
References: 1 2 3 4 5 6
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!fu-berlin.de!uni-berlin.de!not-for-mail
From: antoon.pardon@vub.be (Antoon Pardon)
Newsgroups: comp.lang.python
Subject: Re: Beazley's Problem
Date: Sun, 6 Oct 2024 22:19:10 +0200
Lines: 19
Message-ID: <mailman.4.1728245955.4695.python-list@python.org>
References: <problem-20240921130726@ram.dialup.fu-berlin.de>
<87tte941ko.fsf@nightsong.com>
<newton-20240921151727@ram.dialup.fu-berlin.de>
<87plow4v4p.fsf@nightsong.com>
<0709b4b8b0bbf2a32d53649d1a6fbefbcd44a68a.camel@tilde.green>
<adb3f9c9-6f57-4c1d-a3dc-370a1395c001@vub.be>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: news.uni-berlin.de xwAYXE9Wywb3EyaPmm6irQvwTORpX963N8biVwZL5uNQ==
Cancel-Lock: sha1:WjtsanuLfSDcLHL0crQ8A21m300= sha256:KPy31G4+Rz5IHOUt6pdovXafchihS1cJbxQRbcbp+E0=
Return-Path: <Antoon.Pardon@vub.be>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="1024-bit key; unprotected key"
header.d=vub.be header.i=@vub.be header.b=nmw6S1KN; dkim-adsp=pass;
dkim-atps=neutral
X-Spam-Status: OK 0.013
X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'math': 0.05;
'programming.': 0.05; 'antoon': 0.16; 'from:addr:antoon.pardon':
0.16; 'from:addr:vub.be': 0.16; 'from:name:antoon pardon': 0.16;
'iterative': 0.16; 'iteratively': 0.16; 'message-id:@vub.be':
0.16; 'pardon.': 0.16; 'purely': 0.16; 'root.': 0.16; 'schreef':
0.16; 'solved': 0.16; 'stateless': 0.16; 'problem': 0.16; 'solve':
0.19; 'to:addr:python-list': 0.20; 'written': 0.22; 'programming':
0.25; 'header:User-Agent:1': 0.30; "doesn't": 0.32; 'guess': 0.32;
'header:In-Reply-To:1': 0.34; 'received:52': 0.37; 'something':
0.40; 'best': 0.61; 'point.': 0.62; 'your': 0.64; 'prevent': 0.67;
'functional': 0.69; 'received:52.101': 0.84;
'received:eurprd01.prod.exchangelabs.com': 0.84; 'solvers': 0.84;
'opposite': 0.91
ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none;
b=UQolYCqGck2fTDyUU/pswN49tbYBMkRPVBRCY9UGHIAH+WRPWb+FCknK/Yp1Mljg5U9ugv3kEamDfW+gEyYeC4GzbM803xx7VIys6vVJr5tOJeLMtT+xliArtcodF4sQzxPzKVfs1X0X6klyAIsvUQzRy4NISnBpiPUod9j6nbPmEbHgiUzzHSCoZtQ1ffZJu0ecxpC6GlpzgTDmnv3al4gPk4YC0RS0K7g2QKB+eNLMVHPecId88kITHRRj2z5DC3X6v5oeAcDD+AGb6L4I8zmYJ0Zb80j6pc6XYtSXaSIY5CqBn/FgjhI4a046s7eAm2iSTtfNT+1+tdkgMJ29CA==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com;
s=arcselector10001;
h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1;
bh=MW3eYEEzkOBOTH9f/Y4sGlB/1b67ljoeqFoDIG0CSag=;
b=gArWU2U+SvwwAq/Yx/JnQN9BgXwuDLxs4xuyZ7t76F+jOK3un5EuBmxAvxLX4cgQoks4VJWvwnS+2+oZfFcObrksq48KVEzrxmuF3VXsNx3JHVjNbrdIqFnuPc7RUZ5zx2Wy4NzpPwdiQB/gT0SveSG2FgdN2voq5qvuXMKHAkjqZ7ValbExqSsqZ7WE9kpObvb7GOSykm5S3hlW9jpNCTuvP4pZ/ZSyA4PHMt0UtmdnkjJTuLdPIjxbd8r22kxI/bFzEAmIdu3/ayueY4AZSfocFNOGuWVAbIog1qvyUCipXnA8Hr8Ogd+Hioxo6qRqHTc+ZPdXbjswQafcQWvjUg==
ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass
smtp.mailfrom=vub.be; dmarc=pass action=none header.from=vub.be; dkim=pass
header.d=vub.be; arc=none
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vub.be; s=selector1;
h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;
bh=MW3eYEEzkOBOTH9f/Y4sGlB/1b67ljoeqFoDIG0CSag=;
b=nmw6S1KNkPhZKsH7kbIDTChh+7z70sPjkFTL/6/BKF6gEbcTdPPMinrBH/b3qGYQ8pT+MKAq+R0pwpaN5PMShxYg54loxZm2rgQ0LXgGzLPlBRDVHbFHPK0nCP+O54Gn1LBX6R3r4Q91cE9Y/d1PFeOLG2pwL88i2+3PZbKs8rk=
Authentication-Results: dkim=none (message not signed)
header.d=none;dmarc=none action=none header.from=vub.be;
User-Agent: Mozilla Thunderbird
Content-Language: en-US
In-Reply-To: <0709b4b8b0bbf2a32d53649d1a6fbefbcd44a68a.camel@tilde.green>
X-ClientProxiedBy: AM0PR02CA0218.eurprd02.prod.outlook.com
(2603:10a6:20b:28f::25) To PR3PR01MB7986.eurprd01.prod.exchangelabs.com
(2603:10a6:102:171::5)
X-MS-PublicTrafficType: Email
X-MS-TrafficTypeDiagnostic: PR3PR01MB7986:EE_|PA4PR01MB9090:EE_
X-MS-Office365-Filtering-Correlation-Id: 11258cd5-643c-42c0-37e4-08dce64423f1
X-MS-Exchange-SenderADCheck: 1
X-MS-Exchange-AntiSpam-Relay: 0
X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|1800799024|10070799003|366016;
X-Microsoft-Antispam-Message-Info: 3o5ELnVZL4V8e1jgZ9Kp/6+Vzt6qM9XgVbTeJ7uUuEilG
VJSRd53schJPZwmiqUhkCpqyK17hgUxBJBTrbz4m3vT2Z
L9VS7Xce61FBc4taEdabpa7/qrFD9JZb5bOxiVhfMNVgV
lezHvFOxXgOYTAbSpImdtw1y00vv6WwtGBoDU+FloJdKu
0zq5FdD6MjxRCtDFbmKdml4qn5Z9HSnJgEykNpFriXGcL
gHtOj83Nvnd5nbz9PF1V8z52VVUZqpTTII/56SgpmfZdt
8N5nbkfbOvWJFwLcv37xTkAKOCxaVlBW1r8vwjkMoGzKw
2v3I6+xDwks0rot3w8ruJL+pLvBK2VU6X5Q9ICuBbkCXH
9MhzUBFPLZw4B534AZlBMv/eaxjVVAZa+Z4HudPlLcd3a
Ojow5EbdpsqLAwZsGHcx0NjKtmtih9R+qecTDLua5SLYk
HDCBtXw00UH48nrC17m0L2SmmgvWgLM8YTC+NrG9X7yKc
isQuNIS8Ypi7vyscF6D4XmHDMsFQ6LZkF0yLB6jiRYCDb
Pbhuw3AcO1JlYIyy+KgkMTkjYt8OOjNbvhXvVBcPSswHW
s3OHKPqDzm5vPB8doeEulrtCDDaOAk6N5TX5iD05h9nUP
dc5QbzdVDR0cAiCjNIsRzUIvA5RHrYvSuDZ9E6UqQkjyI
qLqW8E1+phIte8Wxa6u+mvUqPCJOH9RdQBvaBbGEfg2ai
fwr8lvUIT3w9LmTd9h7eZNick8STMjkQAKO19DtSryAD1
01gYQtJnHQpD67VvZjfny7XMSn7Ecc744n2x7ROjjT/Nb
eNYskKZWUQxe/rg9/+WHOCpmireb4fTu4r+2Aexi9T+GQ
OTDV1JnuPxYCydLrGjh1fXywxk1O1zAiJkivSln+Jl0tK
5kN/VcsqqqW8WCyOgrYR/9Y/gAz4u+29lYkQQTdusisQ+
Fu4T/rCXxCblTsW6UB6HG65T5hMOjtPdfmn2CrP88JNi9
3YtHwxj6ierX5HhmJ4qYhy9TTD9+ikdklW03jLiOuTCbs
/MC2IKw0v0ceNVs7now4x5EHJ0c/jyrPDrJPzKvuiyd3T
3C6rmkX2asIztKpUZhMb4Ck8JxH+wPkB3moLWLMJEkW4w
uChnQdvEa9+IOJChD7+UJmQigaP1YyPiuNOrUpUPeIxTR
vAw89KsSBYU8g77FArVlJqKJ4vIC+dXb2uIAZbFOM/NaJ
4XhgOdarYDi5GWIz1XBFjomoptQPIxDwwmbpl+t3LXWPf
mJ33IRvo1w8RQZxCEyzcrEIGBI/C28UJ9ltJtvAJEg==
X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:;
IPV:NLI; SFV:NSPM; H:PR3PR01MB7986.eurprd01.prod.exchangelabs.com; PTR:;
CAT:NONE; SFS:(13230040)(376014)(1800799024)(10070799003)(366016); DIR:OUT;
SFP:1102;
X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1
X-MS-Exchange-AntiSpam-MessageData-0: liCKEdWoadBa3QczDBIGXU/BMsWurNHohV6f0iI3Cz7IO
RZsEKn8nSe3qFWs2j2sSgUD0lQZtqvQlRNWWfx98IdW6t
rfZcr/XX1vesGG8FizJP87O9k8DjpGKTDcYELWiO/Gbh9
j/hbROSjwbSAI098cT5Cc7I/+WbaMCEFm+MNKfTLnIAkp
N9e/ySde+QKwNlkUejI3T1hNjazSk/vjfyfx2UjCFvVYl
xikE1bpQIgDUYO+X+87666fZpyTulYRJqQKcjJsbglgN8
PfO8EbtPrkguIINolzCGqLEA3z9wpEnKJDGXnncMWP18S
aBq/cQet4EFDnzKbt09tem3ST3IWmNanvlIARxEIZJV9k
I791QqLdsh16CRbPs9bRK/qIZnVMdqjq51ReBApWlcSLu
i4z6/BmdPKz9BkKUQbPxcXqOICEie6ftkoJFjjshk2t53
Al5c7IQPEd0kFKJY4cgmW7cRIIs52N6cD9wpI16+AnMhD
80pA1GrkKdDumQc/YIegKkh7ayfCq8LL5T9gUOPiVHFFW
WxsaXAb9HrzfDl/aCpJufPxOlpvcmm3j5cE+xpY7taQDB
mlgsRlcwGi1F41c542+juTVG8ez081xKuwUBMS6YbLr2e
l5fwt2BPu/r2cP8Bv2oUsmw3de0v2oZP4wQDkYdNWFIup
4lSOoEPIOqaIBr1vK1+cjayunlrRPkUE3RiEyhmYYzhHu
O6WVsgJQjR800lSDg4hbb4cpO0QB/MyayW5FBvYn4WLAs
La5cRsctnhI8qknPtfu6Xk0G4W4Q+85skVx8PMRmEV9iA
5dmoEofnkZahlzMUtCjb6HP8AaVrYI6Zpq3qNTpLv3AuE
7OAuFQfPhdBRkWX9kZl/gART8toZtQVaq3AOTZ0VzD9bk
UeLG3wqArSNzc0H+5h18LzTMairZ4rVuRkS4uMGiLLmkI
joaTnOxiFYqMi511sHbGagRVa+x/KyuxVaw/MFGHpJPIJ
aXPHu9Q1EfJg9Ys/qKMZsAQORqnuow9HJOfP+a+nmOrFT
pfQjLShSSiH3XAdXNnB0Se93TP6PvZzNwY9DYQ3Pl0xWC
73uhdThh+fErTOOrNqQf0uJTM/nd8voKBMM9WqX+fy86m
Ne+nGAQkUpHsxh6lM+74JG7hNZHl2hOdC/GOHjAu+H9EK
sikn6SN62tZ6CZ0pA+v63nR5sZAbI3sAFO132kdvuRFA+
aY50iQS2MQuKPw+26eOqcWROCKe+cu2u/hj2mbaLL+jXU
hJmB9lLh4fFAC7YY9eM4D0AqKmZ+vj4kWVwdZdHFPFH0x
s0MuMTozhBjugZ23VW9VT2luzoXYyuG5xwH6j84BS/I7G
lcMiUNGMEKw9EjYZ4tKWZv46C0njQ6qHQBs3Z5sen7ghL
UZZXoinvo7mbMAjrRiSVOGaTB/0xuxhuk1UhIZTrjoBMz
qCgDCsHek0DUmxX/BS6CEhdRqOOJItSmgQVcPymv4R6W1
/gBEJqsGVP077GsTayYv15oOUqBxHQYUNrkOjGaJfRJ5R
lZAW1ZBH4iR133tU1876cTN2gR2WV7FUEOKU0hfRIhECK
KwFAlyhz+h/fDmG9+FyDNZBQ9NGurXYwQc7aXXwMYsLQq
4JqfEPzEtaUEHoGfof8vt0c30TK4EXP2gwWbO7MYFtRC
X-OriginatorOrg: vub.be
X-MS-Exchange-CrossTenant-Network-Message-Id: 11258cd5-643c-42c0-37e4-08dce64423f1
X-MS-Exchange-CrossTenant-AuthSource: PR3PR01MB7986.eurprd01.prod.exchangelabs.com
X-MS-Exchange-CrossTenant-AuthAs: Internal
X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Oct 2024 20:19:11.5896 (UTC)
X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted
X-MS-Exchange-CrossTenant-Id: 695b7ca8-2da8-4545-a2da-42d03784e585
X-MS-Exchange-CrossTenant-MailboxType: HOSTED
X-MS-Exchange-CrossTenant-UserPrincipalName: vmtm4nASWpisoUkffCBJqlfYYmGYHUhBr77V71oU4dgD0EKM8ObA/cewBGF1bzPHHzdmsgfB6UL3n8fOL0TQwA==
X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR01MB9090
X-Content-Filtered-By: Mailman/MimeDel 2.1.39
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <adb3f9c9-6f57-4c1d-a3dc-370a1395c001@vub.be>
X-Mailman-Original-References: <problem-20240921130726@ram.dialup.fu-berlin.de>
<87tte941ko.fsf@nightsong.com>
<newton-20240921151727@ram.dialup.fu-berlin.de>
<87plow4v4p.fsf@nightsong.com>
<0709b4b8b0bbf2a32d53649d1a6fbefbcd44a68a.camel@tilde.green>
View all headers

Op 23/09/2024 om 09:44 schreef Annada Behera via Python-list:
> The "next-level math trick" Newton-Raphson has nothing to do with
> functional programming. I have written solvers in purely iterative
> style.

What is your point. Any problem solved in a functional style can
also be solved in a pure interative style. So you having written
something in an interative style doesn't contradict Newton-Raphson being
expressable in a functional style.
> As far as I know, Newton-Raphson is the opposite of functional
> programming as you iteratively solve for the root. Functional programming
> is stateless where you are not allowed to store any state (current best
> guess root).

That doesn't prevent you from passing state along as a parameter,
usualy in some helper function.

--
Antoon Pardon.

Subject: Re: Beazley's Problem
From: david k. combs
Newsgroups: comp.lang.python
Organization: Public Access Networks Corp.
Date: Sun, 10 Nov 2024 20:48 UTC
References: 1 2 3 4
Path: eternal-september.org!news.eternal-september.org!feeder2.eternal-september.org!border-1.nntp.ord.giganews.com!nntp.giganews.com!weretis.net!feeder9.news.weretis.net!panix!.POSTED.panix1.panix.com!not-for-mail
From: dkcombs@panix.com (david k. combs)
Newsgroups: comp.lang.python
Subject: Re: Beazley's Problem
Date: Sun, 10 Nov 2024 20:48:31 -0000 (UTC)
Organization: Public Access Networks Corp.
Message-ID: <vgr66v$24m$1@reader1.panix.com>
References: <problem-20240921130726@ram.dialup.fu-berlin.de> <0709b4b8b0bbf2a32d53649d1a6fbefbcd44a68a.camel@tilde.green> <Newton-20240923132243@ram.dialup.fu-berlin.de> <87h6a5lx30.fsf@nightsong.com>
Injection-Date: Sun, 10 Nov 2024 20:48:31 -0000 (UTC)
Injection-Info: reader1.panix.com; posting-host="panix1.panix.com:166.84.1.1";
logging-data="2198"; mail-complaints-to="abuse@panix.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Lines: 6
View all headers

Off topic, but quick. Are you the paul rubin who I knew back in 70's in nyc, on E. 84th st?

If so, respond to me at skcombs@optonline.net. Now live in New Rochelle, but winter in
Sarasota, Fla. (like NOW). Phone: 941-954-2029. (Yeah 941 looks like mistyped 914 for
westchester, but 941 IS for sarasota...) Thanks David Combs (now old fart at 82!)

Subject: Re: Beazley's Problem
From: Paul Rubin
Newsgroups: comp.lang.python
Organization: A noiseless patient Spider
Date: Sun, 10 Nov 2024 21:55 UTC
References: 1 2 3 4 5
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: no.email@nospam.invalid (Paul Rubin)
Newsgroups: comp.lang.python
Subject: Re: Beazley's Problem
Date: Sun, 10 Nov 2024 13:55:01 -0800
Organization: A noiseless patient Spider
Lines: 8
Message-ID: <87frnyvjnu.fsf@nightsong.com>
References: <problem-20240921130726@ram.dialup.fu-berlin.de>
<0709b4b8b0bbf2a32d53649d1a6fbefbcd44a68a.camel@tilde.green>
<Newton-20240923132243@ram.dialup.fu-berlin.de>
<87h6a5lx30.fsf@nightsong.com> <vgr66v$24m$1@reader1.panix.com>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Date: Sun, 10 Nov 2024 22:55:03 +0100 (CET)
Injection-Info: dont-email.me; posting-host="cd3eece5d877c77405511975e7039770";
logging-data="622021"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+fzuZCRzga+vULXtZPx8YN"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)
Cancel-Lock: sha1:zKt51sfT+W9xB+5EhigI0XvxAk0=
sha1:c0sTGW4njmMvhIOLDEnoo3isbr4=
View all headers

dkcombs@panix.com (david k. combs) writes:
> Off topic, but quick. Are you the paul rubin who I knew back in 70's
> in nyc, on E. 84th st?

Hey yeah, I'll email you! Way cool. You are still a young feller,
trust me. I spend a lot of time taking care of my mom who is way older
than you ;). I'm in the middle of something but will email today
or can call. Yes I remember New Rochelle :). Good to hear from you!

1

rocksolid light 0.9.8
clearnet tor