You are what you eat, and so are the bacteria that live in your body.

Microbiologists have known for some time that different diets produce different gut flora, but new research indicates that the changes take hold with startling quickness. Bacterial populations shift measurably in the first few days following a big shift in what we eat, according to a recent study.

Researchers assigned volunteers to two diets—one based on animal products such as meat, eggs and cheese and one based on vegetables. Almost immediately the gut microbiome responded. The animal diet, for instance, curbed the numbers of microbes that break down carbohydrates from plants and boosted levels of organisms that can tolerate bile, which helps to digest fats. “What we thought might take days, weeks or years began to happen within hours,” says Eugene Chang, a professor of medicine at the University of Chicago, who did not contribute to the study.

The rapid changes could have been very useful for ancient humans, notes study co-author Lawrence David, an assistant professor at the Duke Institute for Genome Sciences & Policy. A forager's diet could vary widely based on what food sources were available, and the microbiome's ability to adapt would ensure maximum nutrient absorption. David and his colleagues published their findings in Nature. (Scientific American is part of Nature Publishing Group.)

The microbes may not be uniformly beneficial, however. Subjects eating animal products saw a significant uptick in Bilophila wadsworthia, a bacterium known to contribute in mice to colitis, or inflammation of the colon. But David cautions that it is too soon to advocate for specific dietary changes. “We're anticipating that people will try to draw conclusions about which diet is better from this,” David says. “And we want to address that it's very difficult to come to any health-related judgment based on this study.”