still life

python JSON datetime at last

content warning: geeky computer stuff

At work I have a common flow of Python code querying MySQL and dumping results into JSON. This works great except our tables tend to have columns for create and modify dates. And Python's json library won't convert datetime types to string, so dumping the result of "SELECT * FROM" errors. And I've had bits of ad hoc code to remote datetime values, then a little function for it, but it was still a pain. Especially today, when for stupid VPC reasons I'm writing a simple generic SQL service.

In annoyance I tried searching again and found, buried in the middle of a stackoverflow with answers about subclassing and shit:

json.dumps(thing, default=str)

Bam, done. The function passed to 'default' gets invoked on anything that errors at first. And in Python 'str' works on pretty much anything.

If I cared about the exact format I could write a function that inspected type and converted dates (or just assume datetime is the only cause of errors so just invoke a method when triggered), but str is fine for now.

Soooo simple. Thanks, python, and stackoverflow person who gave the simplest answer. See the comment count unavailable DW comments at https://mindstalk.dreamwidth.org/582101.html#comments
CrashMouse, food

pan fried chicken times

I was on the phone with friend A-chan (yes! phone calls!) and describing my dinner in process; she was surprised that I said pan-fried chicken took 35 minutes. That's what I learned from my parents and what usually works well, resulting in cooked but juicy chicken. Sometimes I go longer if the drumsticks (I only do drumsticks) are extra thick. Not that I've experimented much.

I wondered, so looked up fried chicken recipes, and think I see the difference. Most of them talk about filling the pan 1/3 inch to 1 inch deep in oil. So yeah, they might say as little as 15 minutes, or maybe 10 a side, but I imagine it's like deep frying your chicken by parts.

Whereas the oil my family uses is a "don't stick" amount. Probably a couple millimeters at most, if that. So the cooking is partially a dry heat process, pan to chicken. (In fact sometimes my father would brown/sear battered chicken in skillets in batches, then pile them all up in a Dutch oven to finish via baking. I've done that with regular ovens, maybe more often if I'm doing a lot to free friends, but mostly I just do a skillet or sometimes two.)

A side effect of doing that is ending up with a pan rich in seasoned chicken fat, not much diluted by the cooking oil I started with. In my old egg and batter days, I would mix left over seasoned flour with leftover egg, and fry the most amazingly flavorful hockey puck of dough in the pan. These days I just mop up the skillet with bread.

I think I have a strong aversion to filling a pan with oil. Like it seems wasteful of oil or dangerous or messy, or all three. Not really an issue most of the time, but might be why I have trouble cooking corn tortillas; I don't remember my father's process well, and after various failed attempts I suspect it involved pouring more oil than usual, which goes against my "don't stick" habits.

Anyway. These Canadian drumsticks were smaller than is common in the US, so maybe they didn't need 35 minutes. Came out tasty and juicy anyway. See the comment count unavailable DW comments at https://mindstalk.dreamwidth.org/581886.html#comments
angry sky

Is school safe for my kid?

CDC post: https://www.cdc.gov/coronavirus/2019-ncov/science/science-briefs/transmission_k_12_schools.html

My summary:

Q: Can my kids get covid easily?
A: Yes, just as easily as adults. The belief otherwise didn't control for kids having fewer exposures to potential infections.

Q: So is school safe?
A: It can be! If there's universal masking, good ventilation, and cohorting (small groups of kids sticking together, I guess to limit spread if one of them is infectious.) Also weekly testing, especially if you're failing at one of those primary measures. Distancing seems less important except at mealtime -- after all, if you're in a room with someone for an hour without masks or fresh air, distancing really isn't going to help you as you marinate in aerosols.

Q: What does safety actually mean?
A: A good question. As safe as generally being a kid in the community, or even safer (not sure how that works.) Outbreaks still happen, so if you work from home and can have your kid learn at home, that's still safer. But school openings with good measures weren't catastrophic, statistically speaking.

Q: But all those studies are from months ago, before the super infectious Delta; what about now?
A: Who the fuck knows. But I can guarantee that you'll have to be doing *at least* as much as was done in those cases. Universal masking, great ventilation, vaccinate everyone who can get a shot. You don't respond to a more infectious virus by doing less.

Q: But I'm *tired* of masks. I want to go back to *normal*.
A: Are you the parent or the child? Look, imagine that your house had burned down, and you're staying in a motel, and your kid whines about just wanting to go home. Tell yourself what you'd tell them. Assume we're in this long term, indefinitely, then you can be pleasantly surprised if it ever stops for good. See the comment count unavailable DW comments at https://mindstalk.dreamwidth.org/581571.html#comments
Phoenix

sample walkable neighborhood densities

Followup to my old urban densities. All numbers from city-data unless otherwise noted. Units are people per square kilometer. I believe walkability starts being practical around 6000/km2, though that also depends on people actually opening businesses.

Neighborhoods are selected mostly because I've personally experienced them, with a few exceptions.

Albany Park Chicago, 9186
Logan Square Chicago, 8944

Castro SF, 9914
Central Richmond SF, 11867
Chinatown SF, 19657
Chinatown SF, 29,000 (lost source)
Chinatown SF, 100,000 (wikipedia math)
Inner Richmond SF, 12351
Mission SF, 11610
Nob Hill, 22631
Outer Richmond SF, 6272
Outer Sunset SF, 6050
Telegraph Hill SF, 15474
Tenderloin, 16340

Agassiz (south of Porter Square) Cambridge, 6770
Riverside Cambridge, 13601 (not that good an area)
North Cambridge, 6396

Davis Square Somerville 18757 (but 4000 people)
Powderhouse Somerville, 10422 (not that good an area)

Georgetown DC, 4031 (that's it???)

Waterfront/North End Boston, 13164
Chinatown Boston 15090
North End Boston, 10688 (wikipedia)

Paris 11th arrondisement, 41,000 (wikipedia?)

Greenwich Village, 29539
Chinatown NYC, 34749
Upper West Side NYC 42,000
Harlem, 32670

Fishtown Philly 9887 See the comment count unavailable DW comments at https://mindstalk.dreamwidth.org/581132.html#comments
Phoenix

induced demand and transit

So, there's induced demand, the observation since the 1930s that widening a congested road to fix congestion never works. It does do something: it increases bandwidth, allowing more drivers to crawl through congestion. But it doesn't increase speed. Because when demand is high, congestion is the only 'price' that discourages drivers from using the road. Lower the price, and more of them show up until it's high again.

People who learn of this sometimes ask how transit factors in, and I've always said, pessimistically, that it's the same: expanding transit allows more people to bypass congestion -- which is good! -- but won't solve the congestion. Any drivers who take the train will be replaced by more drivers. So the only way to reduce congestion is with actual congestion charges, charging people money to use the road and charging more until you have the levels you want.

But, despite my enthusiasms, I'm an American with American experiences, and I now think I was wrong. At least some of the time. You can watch this Not Just Bikes video or read Wikipedia about the Downs-Thomson paradox or read on:

Imagine that we start with congested roads, and add a subway system that is on average *faster* door to door than driving. As the video says, most people aren't mode bigots (I am! I hate being in cars) and will do whatever is faster (or some mix of faster and cheaper). So if driving is 40 minutes and transit is 25 minutes, lots of people will take the subway. And a good subway system doesn't slow down when heavily used, so it'll keep being 25 minutes even if unpleasantly crowded. Drivers leave the road... and *don't* get replaced, until congestion comes down so much that driving takes less than 25 minutes.

That's the "paradox": "the equilibrium speed of car traffic on a road network is determined by the average door-to-door speed of equivalent journeys taken by public transport." Or by other alternatives, such as bicycling in Amsterdam. If biking were faster than driving, and safe, would you drive most of the time? Probably not. Certainly the Dutch don't. The video guy has said elsewhere that Amsterdam traffic is fairly decent, and this would be why: driving is competing with good bicycling and transit systems, and there's no point to driving to the point that it takes more time than those.

So if you provide good, high-capacity, alternatives to drive, you can reduce congestion!

Now, is this practical? Downs says it's valid in


"regions in which the vast majority of peak-hour commuting is done on rapid transit systems with separate rights of way. Central London is an example, since in 2001 around 85 percent of all morning peak-period commuters into that area used public transport (including 77 percent on separate rights of way) and only 11 percent used private cars. When peak-hour travel equilibrium has been reached between the subway system and the major commuting roads, then the travel time required for any given trip is roughly equal on both modes."


Even for this American, it's hard to imagine such a fast and high capacity transit network. (I was not paying attention to what rush hour driving is like in Osaka.) And it's not like NYC or pre-congestion charge London traffic are/were good, though since NYC transit speeds aren't that high, that might not be a refutation. And of course there are complications: taxis, trucks, and through traffic might contribute traffic that isn't divertible by the alternatives. Conversely, high parking or gas costs could drive people to transit even when slower: what we'd really expect is that people would take the mode that has the lowest cost to them, where the travel cost is a function of time, money, aggravation (overcrowding, weather exposure, being stuck behind a wheel), need to carry things, and maybe more. And as an application of the Law of One Price, people should shuffle between the various modes until the modes have the same average cost.

And this is the problem being an American: we've gone in for cars so much, and scanted the alternative so much, that even with multi-hour rush hours, driving is typically still the fastest and lowest 'cost' mode of getting to work, or anything else. Especially when buses or bicycles get stuck in, or endangered by, cars -- no matter how bad things get, the car is still least bad. This is what killed off streetcars. Subways and bus lanes bypass traffic, as do Dutch (bike paths) or Japanese (wide sidewalks) bicycles.

But as a practical thing... taking a lane of road for bus lanes might actually improve congestion for the cars as well as the buses, by diverting drivers into the buses. If you run enough buses to absorb demand, then the driving speed should come to match the bus rapid transit speed. See the comment count unavailable DW comments at https://mindstalk.dreamwidth.org/581035.html#comments
Phoenix

myths of luxury housing

https://www.strongtowns.org/journal/2021/4/27/are-new-homes-mostly-luxury-does-it-matter-if-they-are

* new construction does lower prices
* most homes are inhabited, and vacancy rates are low in high cost cities; keeping housing off the market isn't a big thing
* "luxury" is a meaningless marketing term, applicable to utterly banal stuff. Also a meaningless term of opprobrium, as when owners of $2 million homes sneer at $500,000 "luxury" condos.
* But what is normal now is more 'luxurious' than in 1971. New apartments come with amenity services like concierge, gyms, pools. Houses have doubled in size and are on larger lots.
* Actual cost of constructing housing hasn't changed much, but costs go up with land cost and size.

* Main thing driving all that is zoning laws: they require large lots, off-street parking, and low levels of density. And when stuff has to be expensive, you aim upmarket, thus gyms.

* Adding my own knowledge here: absuridities like 800 square foot studios can probably be explained by zoning laws requiring more parking for 1BRs than for studios. See the comment count unavailable DW comments at https://mindstalk.dreamwidth.org/580656.html#comments
Phoenix

walkability again

3rd in a series, previous is here.

kchoze had said the US has 8000-12000 people per supermarket, so I've been using 12,000 to be conservative. But a casual websearch turned up the US having 38,000 "supermarkets", or one per 8400 people. Say 8000. Then a density of 8000 people/km2 is walkable like 12,000, one market per square kilometer. And we can apply the checkerboard trick of the previous post, so that even 4,000/km2 has no one more than a kilometer from a supermarket.

There's a simpler approach: instead of thinking in squares, because they're easy to lay out, think in diamonds, the 'circle' equivalent for a grid, all the locations within X distance of a point. If r is the distance from a center to the corner of a diamond/square, the area is 2r^2. So a diamond of 1 km 'radius', trip length, around a supermarket, has area of 2 km2, thus 8000 people at a density of 4,000/km2.

kchoze, and a couple more websearches, indicate that both the US and Japan have a bit over 2000 people per convenience store. If we assume a max of 6 minutes or 0.5 km for a 'convenient' walk, then there's an area of 0.5 km2, or 2000 people at the 4000 density. Just enough to support it, maybe. If we want a 4 minute walk, that needs a density of 9000 people/km2 to get 2000 people. For 2 minutes, like a real 'corner store', you'd need a density of 36,000 people/km2.

Anyway, that seems to be a couple different approaches pointing to a local density of 4000/km2 being the bare minimum for walkability, if laid out just right, with respect to supermarkets and corner/convenience stores. If you want lower density without much car use, make sure people feel safe biking, e.g. by making sure any cars can't go fast. And if you want robust walkability, go higher -- 6000-12000.

I'm not sure about supermarkets in Japan. One source says 5000, so 24,000 people each; another says 20,000, for 6,000 people each. A source has 2384 supermarkets in Canada, for nearly 16,000 people each. Definitions of 'supermarket' may vary. See the comment count unavailable DW comments at https://mindstalk.dreamwidth.org/580398.html#comments
kirin, Enki

low density walkability revisited

I still like my 2019 model of how even 3000 people/km2 can be kind of walkable (and bikable) if you do it right. Short recap: supermarket needs 8-12,000 people, so imagine a 2 km x 2 km superblock, with a market right in the center (along with bus/rail intersection). Furthest walk is 2 km or 24 minutes, from the corners, which isn't great, but many people have shorter walks, especially if density is non-uniform and clumps by the center. And 2km is 10 minutes on a slow bike, so *that's* nice. I also penciled in schools and stores and such.

At 12,000 people/km2 the scaling is easy: you have the same pattern, but in a 1x1 km superblock. Now the longest walk is 12 minutes, super easy, barely an inconvenience.

But what about 6,000? I found that annoying to think about and didn't talk about it last time. Annoyingly supermarkets might need just 8000 people... but that's 1/3 more than I have in 1 km2.

But I realized, if you take the 12,000/km2 model, and then simply remove every other supermarket in a checkerboard pattern, then you have the right population ratio to support the markets, but still no one has to walk more than 12 minutes, 1 km. You've increased the *average* walk time -- a bunch of people who were in 0-3 minutes are now in 9-12 minutes -- but not the max.

Probably not coincidentally, I read somewhere that car use drops off around 10-20 units per acre; if that's gross acre, then that's 2500-5000 units per km2, or 6250-12,500 people/km2 if each unit averages a 2.5 person household.

(And if you're wondering how that compares to real cities, this older post is useful, though sometimes neighbhorhood density would be more useful. But given that cities tend to be largely residential, a US city of 1000-2000 people/km2 is obviously not going to have much walkability.) See the comment count unavailable DW comments at https://mindstalk.dreamwidth.org/580331.html#comments
Phoenix

bus failure

I noticed a failure mode today, of bus stops before an intersection. Bus is at the stop, having exchanged passengers. Light is green. Bus cannot pull left, because of a steady flow of traffic. Bus cannot advance, because a car ahead of it wants to make a right turn, but is waiting for pedestrians to clear. Bus is stuck.

If the stop is on the far side of the intersection, the bus might still not be able to pull left for a while, but it won't have a right turn blockage.

Hmm, OTOH given widespread street parking, the bus can't advance anyway because there are parked cars ahead. For this to work better, you'd need two lanes of traffic and no parking.

Or, of course, you change your priorities, and have bulb-out bus stops so that the bus doesn't have to leave the traffic lane to change passengers. This means the bus may stop cars behind it, but hey, priorities. Bus may have 10-100 people on it, after all. See the comment count unavailable DW comments at https://mindstalk.dreamwidth.org/579841.html#comments