HackerTrans
TopNewTrendsCommentsPastAskShowJobs

raymondh

no profile record

Submissions

Napkin Ring Problem

en.wikipedia.org
2 points·by raymondh·3 yıl önce·0 comments

Tuple Spaces (Or, Good Ideas Don't Always Win)

software-carpentry.org
2 points·by raymondh·3 yıl önce·0 comments

comments

raymondh
·2 ay önce·discuss
In the 1990s, I briefly met Cleve while taking a two-week Matlab course in Natick. During that course that a classmate introduced me to Python, a language where I later became a core developer.

Cleve's papers were an inspiration. I soon published my own matrix package called matfunc. That work was heavily influenced by Cleve Moler and by algorithms in Golub and Van Loan. Even my more recent Python contributions, like the super accurate math.fsum(), math.hypot(), and math.sumprod() functions, have their roots in that fertile time in the Matlab ecosystem. In particular, it newsgroups and lists of papers taught me Cleve's never ending quest to create clean front-ends for numerically sophisticated code.

Thank you Cleve. Your legacy will live forever.
raymondh
·2 yıl önce·discuss
For those who don't know the name, Tim Peters is the author of "The Zen of Python". He is the one who uniquely captured was Python is all about with this inspirational little poem:

    The Zen of Python, by Tim Peters

    Beautiful is better than ugly.
    Explicit is better than implicit.
    Simple is better than complex.
    Complex is better than complicated.
    Flat is better than nested.
    Sparse is better than dense.
    Readability counts.
    Special cases aren't special enough to break the rules.
    Although practicality beats purity.
    Errors should never pass silently.
    Unless explicitly silenced.
    In the face of ambiguity, refuse the temptation to guess.
    There should be one-- and preferably only one --obvious way to do it.
    Although that way may not be obvious at first unless you're Dutch.
    Now is better than never.
    Although never is often better than *right* now.
    If the implementation is hard to explain, it's a bad idea.
    If the implementation is easy to explain, it may be a good idea.
    Namespaces are one honking great idea -- let's do more of those!
Also, he is the author of the famous TimSort algorithm: https://en.wikipedia.org/wiki/Timsort
raymondh
·2 yıl önce·discuss
The reason Guido didn't want 3.6 to guarantee dict ordering was to protect 3.5 projects from mysteriously failing when using code that implicitly relied on 3.6 behaviors (for example, cutting and pasting a snippet from StackOverflow).

He thought that one cycle of "no ordering assumptions" would give a smoother transition. All 3.6 implementations would have dict ordering, but it was safer to not have people rely on it right away.
raymondh
·2 yıl önce·discuss
Thank you AnandTech. Happy ride in to the sunset.
raymondh
·2 yıl önce·discuss
Is there a simple R example for Rule 4?
raymondh
·2 yıl önce·discuss
We should probably get rid of that. It is old (predating numpy) and has limited functionality. In almost every case I can think of, you would be better off with numpy.
raymondh
·2 yıl önce·discuss
This is an impressive post showing some nice investigative work that isolates a pain point and produces a performant work-around.

However, the conclusion is debatable. Not everyone has this problem. Not everyone would benefit from the same solution.

Sure, if your data can be loaded, manipulated, and summarized outside of Python land, then lazy object creation is a good way to go. But then you're giving up all of the Python tooling that likely drove you to Python in the first place.

Most of the Python ecosystem from sets and dicts to the standard library is focused on manipulating native Python objects. While the syntax supports method calls to data encapsulated elsewhere, it can be costly to constantly "box and unbox" data to move back and forth between the two worlds.
raymondh
·2 yıl önce·discuss
We've had to contact the IRS a number of times. It was always difficult to get through. However once we did get through, the representatives were polite, professional, and really seemed to care about achieving case resolution.
raymondh
·2 yıl önce·discuss
Programming Pearls, Thinking Forth, The Little Schemer, and SICP
raymondh
·2 yıl önce·discuss
As described by Alan Kay, what OOP means is encapsulation, messaging, and late-binding.

IIRC the inspiration came from multicellular organisms. A cell "encapsulates" complexity within a cell wall. The organism as a whole works by have the cells work together via "messaging". Any shared interfaces (e.g. oxygen transpiration and nutrient absorption) can be viewed as "polymorphism".

If you buy into the definition and biological analogy, then any language that implements "encapsulation, messaging or polymorphism" actually is OOP and your question is a tautology.
raymondh
·2 yıl önce·discuss
Your nice work on the JS itertools port has a todo for a "better tee". This was my fault because the old "rough equivalent" code in the Python docs was too obscure and didn't provide a good emulation.

Here is an update that should be much easier to convert to JS:

        def tee(iterable, n=2):
            iterator = iter(iterable)
            shared_link = [None, None]
            return tuple(_tee(iterator, shared_link) for _ in range(n))

        def _tee(iterator, link):
            try:
                while True:
                    if link[1] is None:
                        link[0] = next(iterator)
                        link[1] = [None, None]
                    value, link = link
                    yield value
            except StopIteration:
                return
raymondh
·2 yıl önce·discuss
Perhaps Google's AI included TheOnion in its training data:

https://www.theonion.com/geologists-recommend-eating-at-leas...
raymondh
·2 yıl önce·discuss
Numeric towers are indeed a sore point.

* There are more 64-bit integers than C floats/doubles. But in math, reals are a superset of the integers.

* Because floats are rounded, `x < x + 1`, is not an invariant.

* The possibility of a `NaN` value means that the assignment `y = x` does not guarantee that x and y are equal.

* Floats are implemented as binary fractions, so they are actually rationals.

I disagree with the OP that OOP is entirely flawed. The core ideas of encapsulation and messaging are a really useful organizing principle. And polymorphism beats maintaining giant case-statements.

Only when inheritance is added to the mix does it get dicey. As a tool for code reuse, it is not a bad idea. I think the central problem is that people want more from inheritance that it has to give (especially if you expect that children are always substitutable for their parents).
raymondh
·2 yıl önce·discuss
A lot of classic popular songs also had low information content:

https://happyhollyproject.com/2014/04/27/flowcharts-and-song...
raymondh
·2 yıl önce·discuss
The Terminal Man by Michael Crichton
raymondh
·3 yıl önce·discuss
This is a red-herring. In the end, everything is run in machine language which is intrinsically unsafe. But that doesn't matter. High level languages can enforce constraints that eliminate or mitigate common programmer errors for memory access.

For example, it is a simple matter for a language to provide a list or array API that will perform bounds checking for indexed access. This simple measure would have prevented something like the HeartBleed security bug.
raymondh
·3 yıl önce·discuss
What counts as an innovation is in the eye of the beholder. Mark Rober demonstrated Gemini's creative ability by having it suggest a video, details of contents, and how to produce it. The results were impressive but far from world changing: https://www.youtube.com/watch?v=mHZSrtl4zX0
raymondh
·3 yıl önce·discuss
FWIW, there is a recipe for this in the Python docs[0]. It was developed in collaboration with Alan Downey and Tim Peters:

    from random import Random
    from math import ldexp

    class FullRandom(Random):

        def random(self):
            mantissa = 0x10_0000_0000_0000 | self.getrandbits(52)
            exponent = -53
            x = 0
            while not x:
                x = self.getrandbits(32)
                exponent += x.bit_length() - 32
            return ldexp(mantissa, exponent)
[0] https://docs.python.org/3/library/random.html#recipes
raymondh
·3 yıl önce·discuss
Note that this effect varies across builds and versions. For most of Python's history, we could give clear and invariant optimization advice (locals and nonlocals are fastest, global variable access was at least twice as slow, and builtin variable access was even slower). That ordering will likely remain true but absolute speeds have improved dramatically and the ratios have shifted).

Here is a run of Tools/scripts/var_access_benchmark.py for Python 3.12rc1 stock build for an Apple M1 Max (your mileage may vary):

    Variable and attribute read access:
       1.9 ns read_local
       2.4 ns read_nonlocal
       2.8 ns read_global
       4.1 ns read_builtin
       5.0 ns read_classvar_from_class
      12.1 ns read_classvar_from_instance
       4.8 ns read_instancevar
       4.7 ns read_instancevar_slots
      12.2 ns read_namedtuple
      29.0 ns read_boundmethod

    Variable and attribute write access:
       2.4 ns write_local
       2.5 ns write_nonlocal
      10.5 ns write_global
      26.8 ns write_classvar
       4.3 ns write_instancevar
       4.2 ns write_instancevar_slots

    Data structure read access:
       5.7 ns read_list
      11.1 ns read_deque
      10.1 ns read_dict
      10.5 ns read_strdict

    Data structure write access:
       6.2 ns write_list
      11.3 ns write_deque
      11.2 ns write_dict
      12.0 ns write_strdict

    Stack (or queue) operations:
      18.4 ns list_append_pop
      17.8 ns deque_append_pop
      18.1 ns deque_append_popleft
raymondh
·3 yıl önce·discuss
If you repeat the same word, it doesn't count as a rhyme ;-)