dmesg --follow
[ 67100100.000 ] posts.x: Am I in the minority using Sol as my daily driver in Codex?  |   [ 67097280.000 ] posts.x: Full talk on why MCP's context problems are a harness issue, not a protocol issue, and what MCPC does about it:  |   [ 67097280.000 ] posts.x: A lot of the AI world spent the past year calling MCP dead, Anthropic included, with Theo, Gary Tan, and Peter Levels all piling on, even as MCP…  |   [ 67037100.000 ] posts.x: @TheZachMueller Nice one! That’s a warm room, just in time for winter.  |   [ 67035060.000 ] posts.x: Full talk on turning scattered engineering judgment, feature-flag agent included, into something a coding agent can actually use:  |   [ 67035060.000 ] posts.x: A team held a recurring meeting every two weeks for one purpose: deleting feature flags nobody needed anymore. @aorobator, a Senior Software Engineer…  |   [ 67034100.000 ] posts.x: Full talk on Greptile's AI-generated PR data, agent revert rates, and the three-question framework behind merging without human review:  |   [ 67034100.000 ] posts.x: A quarter of the pull requests Greptile reviews every month are now completely or largely AI generated, up from under 1% early last year. @greptile…  |   [ 67018080.000 ] posts.x: Full talk on rumors hardening into facts inside a multi-agent village, and the auto-research loop built to catch it:  |   [ 67018080.000 ] posts.x: A rumor that one agent "might leave" can harden into "is leaving" as it spreads through a multi-agent village, with nobody noticing the shift from…  |   [ 67010820.000 ] posts.x: Full talk on building the harness, from reward hacking to bare metal tuning, behind a 3x kernel speedup:  |   [ 67010820.000 ] posts.x: GPU kernels turn out to be an unusually good match for an agent loop: there's a clear benchmark, and a result that's either faster and correct or it…  |   [ 66968520.000 ] posts.x: Full talk on pitting Claude Code, Codex, and Kimi against a human speedrun record, and why none of them found a novel optimizer to win it:  |   [ 66968520.000 ] posts.x: Two coding agents went up against a community speedrun that human researchers spent two years grinding down, and neither one found a genuinely novel…  |  
corey@gallon.me:~/writing$

The Python Lambda Tutorial You Never Asked For

FIGURE 1 ⋅ The Python Lambda Tutorial You Never Asked For

Let's be real, nobody wakes up in the morning thinking, "You know what I need more of in my life? Python lambda functions." But here we are. Buckle up, because this is the lambda tutorial you didn't ask for -- but secretly need.

Lambda Functions: Anonymous, Lazy One-Liners

Lambda functions, also known as anonymous functions (because naming is overrated), let you squeeze a simple function into a single, no-nonsense line of code:

lambda arguments: expression
  • Arguments: Stuff you feed the function.
  • Expression: What the function spits out. And only one -- don't get greedy.

For instance, incrementing a number by 1, because who has time for def?

lambda x: x + 1

This is equivalent to:

def increment(x):
    return x + 1

It's basically the Netflix of Python functions: fast, easy, and minimal commitment.

When Lambdas Actually Matter

Lambda functions are perfect when:

  • You want a quick-and-dirty function without cluttering your namespace.
  • Passing functions as arguments -- especially with pandas' apply().

Here's an actual example from real-world usage:

df['vector'] = df['content'].apply(lambda x: model.encode(x, normalize_embeddings=True))

Translation:

  • Take each content item from your DataFrame.
  • Turn it into a vector (because vectors are cool).
  • Do it without polluting your script with needless function names.

It's like hiring an intern for a five-minute task -- without having to learn their name.

Lambda Goodness

  • Concise: One-liner code beauty.
  • Functional Programming Friendly: Easily passed around like a hot potato.
  • Cleaner: Prevents namespace pollution, aka fewer things to regret later.

Lambda Badness

  • Single Expression Limitation: Complex logic? Look elsewhere.
  • Debugging Nightmare: Anonymous means nameless means frustration.
  • Overuse Syndrome: Just because you can doesn't mean you should. (Looking at you, regex.)

Quick-and-Dirty Lambda Examples

Sorting a List

Here's where lambdas actually shine - complex sorting that would be a pain in the ass otherwise:

points = [(1, 2), (3, 1), (5, 0)]
sorted_points = sorted(points, key=lambda point: point[1])
print(sorted_points)  # Output: [(5, 0), (3, 1), (1, 2)]

What's happening here? We're telling Python "sort these tuples, but ignore the first number and sort by the second one instead." The lambda grabs each tuple, extracts the second value (point[1]), and sorted() does the rest. Without lambdas, you'd need a whole separate function for this trivial operation. Bloody waste of code.

Filtering a List

When you need to separate the wheat from the chaff:

numbers = [1, 2, 3, 4, 5]
even_numbers = list(filter(lambda x: x % 2 == 0, numbers))
print(even_numbers)  # Output: [2, 4]

The filter() function is expecting another function that returns True or False. Our lambda takes each number, divides by 2, and checks if there's a remainder. No remainder? It's even, keep it. Otherwise, chuck it. The result is only the even numbers making it through the filter. It's like a bouncer at a club where odd numbers aren't cool enough to get in.

Transforming a List with Map

Need to apply the same operation to every item in a list? map() + lambda is your friend:

numbers = [1, 2, 3, 4]
squared_numbers = list(map(lambda x: x ** 2, numbers))
print(squared_numbers)  # Output: [1, 4, 9, 16]

Here, map() takes our lambda and applies it to each number in the list. The lambda just squares whatever it gets. So simple it's almost boring, but that's the point. You don't need a whole function definition ceremony for something this straightforward. It's the difference between sending a text and writing a formal letter – sometimes you just need to get the message across without the fluff.

Wrap-Up: Lambdas in a Nutshell

Lambda functions are your go-to for simple, anonymous tasks that aren't worth the full-blown function definition. Sure, they're limited. Yeah, debugging them is annoying. But when used wisely, they're elegant as hell.

So next time you need a function that's here for a good time -- not a long time -- reach for lambda.

And that's it. Tutorial over. Go forth and lambda responsibly (or don't -- I'm not your boss).

corey@gallon.me:~$ tail -f /writing Attach to the stream. An email when I have something worth sending. Replies encouraged!
corey@gallon.me:~$ ls -lt /writing ↑2025-03-20 ⚡️ Latent Space - The new OpenAI Agents Platform
▸2025-03-19 The Python Lambda Tutorial You Never Asked For ⋅ you are here
↓2025-03-18 Founders #383: Todd Graves' $10B Chicken Finger Dream