frontpage.
newsnewestaskshowjobs

Open Source @Github

fp.

Open in hackernews

Elliptical Python Programming

https://susam.net/elliptical-python-programming.html
184•sebg•1y ago

Comments

benob•1y ago
TIL that in python, 1--2==3
seplox•1y ago
It's not a python thing. 1-(-2), distribute the negative.
qsort•1y ago
In most C-like languages that would be a syntax error. E.g. in C and C++ as a rule you tokenize "greedily", "1--2" would be tokenized as "1", "unary decrement operator", "2", which is illegal because you're trying to decerment an rvalue.

Python doesn't have "--", which allows the tokenizer to do something else.

nyrikki•1y ago
In C, that is really because Unary minus (negation) has precedence over binary operations.

    +a - b; // equivalent to (+a) - b, NOT +(a - b)
    -c + d; // equivalent to (-c) + d, NOT -(c + d)

https://en.cppreference.com/w/cpp/language/operator_arithmet...

    +-e; // equivalent to +(-e), the unary + is a no-op if “e” is a built-in type
     // because any possible promotion is performed during negation already
The same doesn't apply to, !! Which is applied as iterated binary operations (IIRC)

I am pretty sure the decriment operator came around well after that quirk was established.

seanhunter•1y ago
Peter van der Linden’s book “Expert C Programming” (which is awesome btw) says that one of them (Kernighan, Richie or maybe Ken Thompson I forget) realised early on that the c compiler had the wrong operator precedence for bit twiddling and unary and boolean operators but “at that stage we had a few thousand lines of C code and thought it would be too disruptive to change it”
j2kun•1y ago
Also worth noting that `1 - -2` works and produces 3 in C because the space breaks the operator.
plus•1y ago
For those who are curious, `...` is a placeholder value in Python called Ellipsis. I don't believe it serves any real purpose other than being a placeholder. But it is an object and it implements `__eq__`, and is considered equal to itself. So `...==...` evaluates to `True`. When you prefix a `True` with `-`, it is interpreted as a prefix negation operator and implicitly converts the `True` to a `1`, so `-(...==...)` is equal to `-1`. Then, you add another prefix `-` to turn the `-1` back into `1`.

`--(...==...)--(...==...)` evaluates to `2` because the first block evaluates to 1, as previously mentioned, and then the next `-` is interpreted as an infix subtraction operator. The second `-(...==...)` evaluates to `-1`, so you get `1 - -1` or `2`.

When chaining multiple together, you can leave off the initial `--`, because booleans will be implicitly converted to integers if inserted into an arithmetic expression, e.g. `True - -1` -> `1 - -1` -> `2`.

> There should be one-- and preferably only one --obvious way to do it.

This article is obviously completely tongue-in-cheek, but I feel the need to point out that this sentence is not meant to be a complete inversion of the Perl philosophy of TIMTOWTDI. The word "obvious" is crucial here - there can be more than one way, but ideally only one of the ways is obvious.

pletnes•1y ago
Numpy actively uses … to make slicing multidimensional arrays less verbose. There are also uses in FastAPI along the lines of «go with the default».
abuckenheimer•1y ago
excellent explanation, to add to this since I was curious about the composition, '%c' is an integer presentation type that tells python to format numbers as their corresponding unicode characters[1] so

'%c' * (length_of_string_to_format) % (number, number, ..., length_of_string_to_format_numbers_later)

is the expression being evaluated here after you collapse all of the 1s + math formatting each number in the tuple as a unicode char for each '%c' escape in the string corresponding to its place in the tuple.

[1] https://docs.python.org/3/library/string.html#format-specifi...

elijahbenizzy•1y ago
Ok do this but for JavaScript
voidUpdate•1y ago
https://en.wikipedia.org/wiki/JSFuck
mariocesar•1y ago
If you're curious, the code in ellipsis results in executing:

    print('hello, world')
mturmon•1y ago
Thank you!

I noticed some ** and * in the thing sent to eval(), which (given that the building blocks are small integers) seemed related to prime factorizations.

The initial %c is duplicated 21 times (3*7, if I read correctly), and then string-interpolated (%c%c%c...) against a long tuple of integers. These integers themselves are composed of products of factors combined using * and **.

There is also one tuple "multiplication" embedded within that long tuple of integers -- (a,b)*2 = (a,b,a,b). That is for the 'l' 'l' in "hello".

It's all very clever and amusingly mathy, with a winking allusion to the construction of natural numbers using sets. It made me Godel.

callamdelaney•1y ago
I think we're really starting to over crowd pythons syntax and I'm not a fan.
noddleah•1y ago
you're telling me you never program in python elliptically??
acbart•1y ago
Pretty sure this would have been possible in Python 2.6. The Ellipsis object has been around for a very long time.
MadVikingGod•1y ago
This behavior can be replicated with any class that has two special methods: __neg__ that returns -1 and __sub__ that accepts ints and returns 1-other.

For example if you make this class:

  class _:
       def __neg__(self):
           return -1
       def __sub__(self, other):
           return 1-other
You get similar behavior:

  >>> --_()
  1
  >>> _()--_()
  2
Fun python for everyone.
maxloh•1y ago
You can do this on JavaScript too.

  alert(1)
  // equals to:
  [][(![]+[])[+!+[]]+(!![]+[])[+[]]][([][(![]+[])[+!+[]]+(!![]+[])[+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+!+[]]+(!![]+[])[+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+!+[]]+(!![]+[])[+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+!+[]]+(!![]+[])[+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]]((![]+[])[+!+[]]+(![]+[])[!+[]+!+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]+(!![]+[])[+[]]+([][(![]+[])[+!+[]]+(!![]+[])[+[]]]+[])[+!+[]+[+!+[]]]+[+!+[]]+([]+[]+[][(![]+[])[+!+[]]+(!![]+[])[+[]]])[+!+[]+[!+[]+!+[]]])()
https://jsfuck.com/
nomel•1y ago
Expanding on this a little, I will be replacing all occurrences of 2 with two blobs fighting, with shields:

    >>> 0^((...==...)--++--(...==...))^0
    2
rmah•1y ago
>> There should be one-- and preferably only one --obvious way to do it.

Except for package management, of course. There, we need lots and lots of ways.

blooalien•1y ago
And apparently string formatting which should have an ever growing number of ways to handle it. :shrug:

Amazon vs. Perplexity – U.S. Court of Appeals for the Ninth Circuit

https://law.justia.com/cases/federal/appellate-courts/ca9/26-1444/26-1444-2026-08-04.html
73•neom•33m ago•53 comments

A single firm is behind OpenAI, Anthropic, and Meta hacking scandals

https://www.effort.news/irregular
12•yusufozkan•24m ago•0 comments

Distributed Systems Classics (2017)

https://nvartolomei.com/dist-sys-classics/
187•grep_it•5h ago•37 comments

A Beginning for Mathematics

https://www.daniellitt.com/blog/2026/9/13/a-beginning-for-mathematics/
134•robinhouston•6h ago•64 comments

Principles for Fast Tokio Applications

https://dial9-rs.github.io/blog/principles-for-fast-tokio-applications/
137•carllerche•6h ago•25 comments

OpenAI bots knew about the RubyGems caching vulnerability

https://tenderlovemaking.com/2026/09/11/what-a-time-to-be-alive/
304•gregnavis•8h ago•270 comments

How my e-reader lost its stripes

https://www.serpentine.com/posts/2026/x3-stripes/
97•simonmic•5h ago•11 comments

Oracle’s 6am layoff emails hit staff amid new wave of cuts

https://www.techtimes.co.uk/oracle-new-layoffs-restructuring-costs-2-8-billion-1808676
106•akis33•2h ago•71 comments

XCancel service is suspended until further notice

https://xcancel.com/#
345•gaganyaan•11h ago•637 comments

Why don't machine learning research agents overfit?

https://www.amazon.science/blog/why-dont-machine-learning-research-agents-overfit
86•Betelbuddy•5h ago•50 comments

Cloudflare AKE cuts origin HelloRetryRequests from 52% to 3.7%

https://blog.cloudflare.com/automatic-key-exchange-for-origins/
62•iamsyr•4h ago•17 comments

Pion, an agent designed to run any company autonomously

https://andonlabs.com/blog/why-we-built-pion
206•lukaspetersson•4h ago•223 comments

Optimizing a Spin-Lock

https://david.alvarezrosa.com/posts/optimizing-a-spin-lock/
16•signa11•2d ago•4 comments

Show HN: Neobrutalism.dev – Just added Base UI support and added new color theme

https://www.neobrutalism.dev/
111•samke-•5h ago•50 comments

Cua (YC P25) Is Hiring a Founding Technical GTM Lead

https://www.ycombinator.com/companies/cua/jobs/1IWEKVH-founding-technical-gtm-lead
1•frabonacci•4h ago

Show HN: Nari Qwen3-TTS and Qwen3-ASR – High accuracy, low latency and cost

https://narilabs.com/blog/nari-labs-leads-coval-voice-ai-benchmarks/
44•toebee•5h ago•10 comments

Notes on gotchas while migrating 35kb preprompts from Opus to self-hosted Ollama

https://patrickmccanna.net/notes-on-migrating-large-prompts-away-from-anthropic-openai-to-self-ho...
104•0o_MrPatrick_o0•7h ago•48 comments

Microsoft patches Windows and Excel – breaks audio, remote access, and paste

https://www.theregister.com/os-platforms/2026/09/14/microsoft-patches-windows-and-excel-breaks-au...
155•Alephinitesimal•5h ago•74 comments

Dario, Please

https://pop.rdi.sh/dario-please/
88•0x5FC3•6h ago•33 comments

An atlas of periodic solutions to the three-body problem

https://www.threebodyorbits.com/
311•danielmorozoff•2d ago•70 comments

Ask HN: What are you working on? (September 2026)

278•david927•1d ago•858 comments

Truncated SVD (2023)

https://brashandplucky.com/2023/09/09/truncated-svd.html
39•ibobev•5h ago•6 comments

Steam Frame starts at $1059

https://store.steampowered.com/hardware/steamframe
401•bsimpson•4h ago•273 comments

iOS 27, iPadOS 27, and macOS 27

https://www.apple.com/newsroom/2026/09/major-updates-for-apples-software-platforms-are-now-availa...
270•throw0101d•3h ago•272 comments

Adversarial Fashion Makes a Statement on AI Panopticon

https://spectrum.ieee.org/adversarial-fashion
83•rbanffy•7h ago•41 comments

Show HN: Apollo Lunar Module landing simulation

https://gosandeep.com/eagles-descent/
28•gosandeep•5d ago•2 comments

EuroBirdPortal – Live bird movements across Europe

https://www.eurobirdportal.org/ebp/en/
208•NKosmatos•13h ago•62 comments

Show HN: Pelican-bicycle alternatives

https://gally.net/temp/20260914pelican-alternatives/index.html
97•tkgally•8h ago•39 comments

Trying to Make a Loop Auto-Vectorize

https://jsgroth.dev/blog/posts/trying-to-make-a-loop-auto-vectorize/
56•zdw•4d ago•14 comments

GPT-5.6 Luna vs. GPT-6 Astra: Is a $1.20 Model Good Enough for Code Review?

https://entelligence.ai/blogs/gpt-5.6-luna-vs-gpt-6-astra-is-a-1.20-model-good-enough-for-code-re...
62•theanonymousone•1h ago•77 comments