dmesg --follow
[ 66243600.000 ] posts.x: Full talk on what's changed in quantization, KV caching, and speculative decoding since Philip's book came out:  |   [ 66243600.000 ] posts.x: A quantization method called TurboQuant promised to shrink the KV cache down to four bits this year, then turned out to cut tokens per second by more…  |   [ 66230100.000 ] posts.x: Curious what The Godfather thinks of this. @HamelHusain  |   [ 66229560.000 ] posts.x: @lukebfox1 This was such a great game! We used to have all-night LAN parties on this one!  |   [ 66229440.000 ] posts.x: Astounding!  |   [ 66179400.000 ] posts.x: Full talk on the harness layers, the files-vs-databases tradeoff, and context rot:  |   [ 66179400.000 ] posts.x: Most of what makes an AI agent reliable has nothing to do with the model itself. In "Total Recall: Agent Memory and Harness Engineering,"…  |   [ 66169620.000 ] posts.x: Full talk on why AI cluster networks need a receiver-driven, message-based protocol instead of TCP:  |   [ 66169620.000 ] posts.x: Most AI clusters still tune their networks for giant weight transfers, but the workloads pushing performance limits now are tiny messages: a KV cache…  |   [ 66168660.000 ] posts.x: Full talk on why llms.txt isn't enough and what actually makes a website agent-ready:  |   [ 66168660.000 ] posts.x: Almost half of the websites in one study already publish an llms.txt file for agents to read, but almost none of the agents actually use it…  |   [ 66166560.000 ] posts.x: @hypeapps @toggl You could still get pretty close. Agent sessions are stored on disk. Subtract the long gaps between your inputs to the session…  |   [ 66166140.000 ] posts.x: @hypeapps @toggl Is this because you’re straddling multiple agent sessions for multiple projects simultaneously?  |   [ 66159420.000 ] posts.x: Full talk on why there's no single right chunk size and how multiscale indexing with RRF closes the gap:  |   [ 66159420.000 ] posts.x: A fixed chunk size is a bet on queries you haven't seen yet. @yuvalinthedeep, Sr. Developer Advocate at AI21, tests that bet in "Stop Chunking Like…  |  
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