Readit News logoReadit News
raymondh commented on Tim Peters – Dispelling Information Asymmetry   tim-one.github.io/psf/ban... · Posted by u/shazeline
raymondh · a year ago
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 commented on Lesser known parts of Python standard library   trickster.dev/post/lesser... · Posted by u/rbanffy
ericvsmith · 2 years ago
See my comment and the linked email at https://github.com/ericvsmith/dataclasses?tab=readme-ov-file... for dataclasses and 3.6. I think it's still true.
raymondh · 2 years ago
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 commented on AnandTech Farewell   anandtech.com/show/21542/... · Posted by u/janice1999
raymondh · 2 years ago
Thank you AnandTech. Happy ride in to the sunset.
raymondh commented on Seven basic rules for causal inference   pedermisager.org/blog/sev... · Posted by u/RafelMri
raymondh · 2 years ago
Is there a simple R example for Rule 4?
raymondh commented on Python extensions should be lazy   gauge.sh/blog/python-exte... · Posted by u/0x63_Problems
tomjakubowski · 2 years ago
re: 3, Python has a native numeric array type https://docs.python.org/3/library/array.html
raymondh · 2 years ago
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 commented on Python extensions should be lazy   gauge.sh/blog/python-exte... · Posted by u/0x63_Problems
raymondh · 2 years ago
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 commented on Millions of Taxpayers Call the IRS for Help. Two-Thirds Don't Reach Anyone   wsj.com/personal-finance/... · Posted by u/impish9208
raymondh · 2 years ago
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 commented on Ask HN: What brought back the joy of programming for you?    · Posted by u/endorphine
raymondh · 2 years ago
Programming Pearls, Thinking Forth, The Little Schemer, and SICP
raymondh commented on The Numeric Tower Fiasco   mmapped.blog/posts/23-num... · Posted by u/tie-in
mrkeen · 2 years ago
> 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.

Does OOP actually do encapsulation, messaging or polymorphism better than other languages though?

raymondh · 2 years ago
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 commented on More Itertools   more-itertools.readthedoc... · Posted by u/stereoabuse
jacobolus · 2 years ago
You can implement quite a lot of Python's itertools in Javascript without too much trouble. For instance, https://observablehq.com/@jrus/itertools

Disclaimer: this code was written several years ago with few downstream users, not all of these are super high performing, and they have not been super extensively tested.

raymondh · 2 years ago
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

u/raymondh

KarmaCake day2427February 9, 2010
About
Highlights:

  * CEO of Mutable Minds, Inc. (a training and consulting company)
  * Python Distinguished Service Award
  * Past Python Software Foundation (PSF) board member
  * Private pilot (single engine land and sailplanes)
  * Certified Public Accountant
  * Certified Internal Auditor
  * Python Core Developer
  * Husband to Rachel
  * Father to Matthew
Python training video series, "Modern Python: Big Ideas, Little Code" available for free to Safari On-line subscribers: https://www.oreilly.com/library/view/modern-python-livelessons/9780134743400/

Videos for conference presentations and keynotes can be found at: https://www.youtube.com/playlist?list=PLRVdut2KPAguz3xcd22i_o_onnmDKj3MA

Contributions to Python:

  * any()
  * all()
  * enumerate()
  * local mapping argument to exec() can be any mapping
  * filter() -- originally itertools.ifilter
  * frozenset()
  * map() -- originally itertools.imap
  * reversed()
  * sum() -- optimized and made more accurate
  * zip() -- originally itertools.izip
  * sorted()
  * set()
  * dict.fromkeys
  * dict.pop
  * float.as_integer_ratio
  * str.format_map
  * str.partition
  * str.rpartition
  * tuple.count
  * tuple.index
  * abc.ABC
  * antigravity.geohash 
  * bisect module -- key function support
  * calendar module -- various fixups
  * collections.ChainMap
  * collections.Counter
  * collections.OrderedDict
  * collections.deque
  * collections.namedtuple
  * contextlib.redirect_stderr
  * contextlib.redirect_stdout
  * contextlib.suppress
  * decimal module
  * difflib.context_diff
  * difflib.unified_diff
  * fractions.limit_denominator -- with Mark Dickinson
  * functools.cache
  * functools.cmp_to_key
  * functools.lru_cache
  * functools.total_ordering
  * heapq.heappushpop
  * heapq.merge
  * heapq.nlargest
  * heapq.nsmallest
  * itertools.accumulate
  * itertools.chain
  * itertools.chain.from_iterable
  * itertools.combinations
  * itertools.combinations_with_replacement
  * itertools.compress
  * itertools.count
  * itertools.cycle
  * itertools.dropwhile
  * itertools.filterfalse
  * itertools.groupby
  * itertools.islice
  * itertools.pairwise
  * itertools.permutations
  * itertools.product
  * itertools.repeat
  * itertools.starmap
  * itertools.takewhile
  * itertools.tee
  * itertools.zip_longest
  * json.AttrDict (later removed)
  * math.dist
  * math.fsum -- with Mark Dickinson
  * math.hypot -- improve algorithm and expanded to n-dimensional case
  * math.log -- added the "base" optional argument
  * math.prod -- implemented by Pablo Galindo
  * operator.attrgetter
  * operator.itemgetter
  * queue.LifoQueue
  * queue.PriorityQueue
  * queue.join
  * queue.task_done
  * random's MersenneTwister
  * random.SystemRandom
  * random._randbelow
  * random.binomialvariate
  * random.choices
  * random.sample
  * random.triangular
  * statistics.correlation -- added spearman rank correlation coefficient
  * statistics.fmean
  * statistics.geometric_mean
  * statistics.harmonic_mean -- added weights parameter
  * statistics.kde
  * statistics.kde_random
  * statistics.linear_regression -- added direct proportion option
  * statistics.mode -- fixed api
  * statistics.multimode
  * statistics.NormalDist
  * statistics.quantiles
  * statistics.variance/pvariance/stdev/pstdev -- correctly ounded
  * tokenize.untokenize
  * userdict.DictMixin -- eventually became ollections.MutableMapping
  * __slots__ can be a dictionary
Designer of:

  * key-functions
  * generator expressions
  * compact and ordered dictionaries
  * the peephole optimizer
  * __length_hint__ optimization
  * the thousands separator in string formatting
  * original proponent of exception chaining
  * original proponent of sending data and exceptions into enerators
  * eval-loop opcode prediction
Maintainer of:

  * the argparse module (successor to Steven Bethard)
  * the bisect module
  * the collections module
  * the collections.abc module
  * the decimal module
  * the heapq module
  * the itertools module
  * the queue module
  * the random module
  * the statistics module (with Steven D'Aprano) 
Author of:

  * Python How-to: Descriptor Guide
  * Python How-to: Sorting Techniques
  * Python tutorial: Looping Techniques
  * Python tutorial: Tour of the standard library
  * Python tutorial: Floating Point Arithmetic
  * Blog post: Super Considered Super
  * Whatsnew 3.1
  * Whatsnew 3.2
  * Whatsnew 3.8
Social media:

  * https://twitter.com/raymondh
  * https://rhettinger.wordpress.com/
  * https://www.facebook.com/raymondh
  * https://www.linkedin.com/in/raymondhettinger/
  * https://stackoverflow.com/users/1001643/raymond-hettinger

View Original