In effect, the de Blasio administration prevented the library from making a larger bundle by stressing subsidized housing. But all these public-private ventures involve trade-offs. This one seems equitable. Whether this deal looks reasonable in the end will depend on the quality of the offsite housing and the new branch.

The Sunset Park deal, in a less affluent neighborhood, is a different case, growing out of community demands for subsidized housing and a bigger library. The existing 12,000-square-foot branch on Fourth Avenue at 51st Street is a bunker. A seven-story tower with some 50 units of affordable housing would rise in its place above a 20,000-square-foot library. The developer is the local nonprofit Fifth Avenue Committee. No architect has been chosen yet. With tax credits, the tower should pay for the shell of the new branch. That means another $10 million would still be needed to outfit the place — but that’s half the cost of a new, stand-alone library.

Once upon a time, libraries didn’t need to act like real estate entrepreneurs, wheeling and dealing. When Andrew Carnegie donated the branches, beginning in 1899, one of the great philanthropic acts in American history, New York City contracted to maintain them and keep them open 72 hours a week in perpetuity. But it reneged years ago. The branches are now open 43 hours a week, and not on Sundays, when millions of people need them most. With circulation soaring and 36 million visitors using the branches in 2013 (nearly 40 million, if you count the research and main libraries), there’s more reason than ever to renew the city’s obligation.

That’s especially the case for Mayor Bill de Blasio, because the 200-plus branches across the three systems (Brooklyn; Queens; and New York, which oversees Manhattan, Bronx and Staten Island) align with the mayor’s agenda. They cater to pre-K toddlers, after-school teenagers, seniors, the unemployed looking for job training, and immigrants learning English as a second language. Nearly 150 branches are in or near flood zones. More than a few became safe havens after Hurricane Sandy.