When Sonia Sotomayor was 7 years old and hospitalized with diabetes, she learned to give herself insulin shots by practicing on an orange. At home, her mother showed her how to light a burner on the stove with a match, and together they would fill a pot with water to cover the syringe and needle. Sonia was taught to wait for a boil and then to wait five minutes more. The daily shots became her way of fending off conflict between her parents: Her father’s hands trembled because of his alcoholism, and her mother, a nurse who worked long hours, would get angry when she couldn’t rely on him. “The last thing I wanted was for them to fight about me,” Sotomayor relates in her new memoir. “It then dawned on me: If I needed to have these shots every day for the rest of my life, the only way I’d survive was to do it myself.”

It’s a childhood memory that remains strong. It also contains the elements — ­resourceful intelligence, acute sensitivity to family, and self-reliance — that would one day propel the little girl at the stove to the Supreme Court. “I’ve spent my whole life learning how to do things that were hard for me,” Sotomayor tells an acquaintance many years later, when he asks whether becoming a judge will be difficult for her. Yes, she has. And by the time you close “My Beloved World,” you understand how she has mastered judging, too.

This is not a confessional memoir. Sotomayor discloses little about her marriage, in her 20s, to her high school sweetheart, or about their divorce. She is coy about how her years as a student at Yale Law School, in the late 1970s, may have shaped her legal views. The book ends as Sotomayor reaches the bench as a federal district judge in New York, so she offers no juicy bits, or even bland ones, about her nomination to the Supreme Court, or its work or her colleagues. That can be the sequel.

Meanwhile, this book delivers on its promise of intimacy in its depictions of Sotomayor’s family, the corner of Puerto Rican immigrant New York where she was raised and the link she feels to the island where she spent childhood summers eating her fill of mangoes (always keeping an eye on her blood sugar level). This is a woman who knows where she comes from and has the force to bring you there. Sotomayor does this by being cleareyed about the flaws of the adults who raised her — she lets them be complicated. Her grandmother’s South Bronx apartment was Sotomayor’s safe harbor, a place of music and the “happiest smells” of garlic and onions. But her grandmother blamed Sotomayor’s mother for her son’s drinking, even as it turned him into a kind of monster. “I saw my father receding from us, disappearing behind that twisted mask,” Sotomayor writes of watching him drink at parties. “It was like being trapped in a horror film, complete with his lumbering Frankenstein walk as he made his exit and the looming certainty that there would be screaming when we got home.”

Sotomayor’s father died when she was 9, and she thinks to herself, with the sharp pragmatism of a child that age, “Maybe it would be easier this way.” But Sotomayor’s mother did not rise with relief from her loss; she shut herself in her dark bedroom for a long season of grief. So Sotomayor became a library rat, though without any guidance. (She’d never heard of “Alice in Wonderland” until she got to Princeton years later.) Finally, after months of lonely reading and evenings spent silent with her younger brother in front of the television, Sotomayor literally hurled herself at her mother’s door and screamed at her not to die too. It’s another example of her will, and of her instinct for self-preservation. She tells us that her anger with her mother lingered — another bracing dose of honesty. But she also credits her mother with taking steps to better her children’s future: speaking English with them; buying the Encyclopaedia Britannica.

Sotomayor responded by figuring out how to excel in school. She asked the smartest girl in her class how to study. In high school, she joined a debating team, and learned how to structure an argument and speak in public. An older student told her about something she’d never heard of — the Ivy League — and she followed him to Prince­ton. “Qualifying for financial aid was the easiest part,” she writes. “There were no assets to report.”

For all her reticence in discussing her legal views, Sotomayor is frank about how much she benefited from affirmative action. (The constitutionality of race-conscious university admissions is on the court’s docket this year, with a case brought by a white plaintiff denied entrance to the University of Texas.) She received a C on her first midterm paper because she didn’t know how to write an essay. And she remembers regular letters to The Daily Princetonian complaining that students like her were displacing worthier applicants. Sotomayor dealt with all this by joining a Puerto Rican student group that concentrated on recruiting more Latino students. Hardly a radical, she was more the type that got tapped for a ­student-faculty committee. In class, she spun her self-doubt into motivation and won the Pyne Prize, the highest award Princeton gives to a senior, as well as graduating summa cum laude and Phi Beta Kappa. Her account of these years is a textbook description of grit. “That tide of insecurity would come in and out over the years, sometimes stranding me for a while but occasionally lifting me just beyond what I thought I could accomplish,” she writes. “Either way, it would wash over the same bedrock certainty: ultimately, I know myself.”

That self-knowledge isn’t just about striving. It also enables Sotomayor to see that when she’s hard at work, she sometimes misses social cues. At the law firm she later joined, a colleague called her “one tough bitch.” Stung, she has made sure since then to hang on to a secretary who “holds a mirror up when she notices me getting intimidating or too abrupt, an effect only amplified by the trappings of my current office.” This passage deftly turns aside the anonymous (and refuted) attacks on Sotomayor’s temperament before her 2009 nomination to the Supreme Court.

I’m all for kindness from on high, but I’m glad Sotomayor still fires aggressive questions from the bench. Watching her recently, I thought of the mock juror who once told her, back in her law-student days, that he had voted against her because he didn’t like brassy Jewish women. Good for her for staying brassy, and for telling this story without sweating it.

In this, as in her stance on affirmative action, Sotomayor’s memoir contrasts with Clarence Thomas’s 2007 autobiography, “My Grandfather’s Son.” Where she learned to see school as her giant oyster, and to shrug off the world’s slights, Thomas emerged from his hardscrabble upbringing in a defensive crouch, deriding college and law school for turning him into an “educated fool.” No wonder the two justices of color have such divergent voting records. Their future years on the bench will reveal which book, and which lessons learned in childhood, will have more influence.

Emily Bazelon is a senior editor at Slate and the Truman Capote fellow at Yale Law School. Her book about bullying,“Sticks and Stones,” will be published next month.