• Modern Optimization (was: Beazley's Problem)

    From Stefan Ram@21:1/5 to Stefan Ram on Thu Sep 26 12:51:13 2024
    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.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Stefan Ram@21:1/5 to Stefan Ram on Thu Sep 26 12:54:34 2024
    ram@zedat.fu-berlin.de (Stefan Ram) wrote or quoted:
    (names, not values; i.e., "obj.dict.keys()" shouldn't

    obj.__dict__.keys()

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Gilmeh Serda@21:1/5 to Stefan Ram on Thu Sep 26 16:13:55 2024
    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

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From david k. combs@21:1/5 to All on Sun Nov 10 20:48:31 2024
    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!)

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Paul Rubin@21:1/5 to david k. combs on Sun Nov 10 13:55:01 2024
    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!

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)