Lima is just as safe as any other major city in the world at night. Which means, if you don't have your wits about you, it isn't safe. If you do, it is. (Relatively speaking)
Peru relies quite heavily on tourism, so more systems have been put in place by authorities to make sure visitors to the country are not disturbed. There is a heavy police presence in Lima, including placement of plain clothed police officers - especially in areas visited by tourists. So in some respects, for a visitor, Lima is safer than major cities in the west.
Although as a general rule, the more precautions you take, the safer you will be.
Bus rides at night are generally considered to be fairly safe - but take precautions. Keep your luggage close to you and keep an eye out for pickpockets.
Try to travel in taxis that are located in established areas like airports and hotels. Avoid taxis that cannot provide official identification.
The biggest problem you will face is deceptive gentlemen (and ladies) who will try to distract you in some way to make off with your wallet. So, if you find someone trying to get your attention, be cautious. And don't flash any valuables or highly branded clothing items - it's essentially screaming "I have a stack of cash come and rob me".
Don't carry a lot of money on you, and if you do get robbed - simply give the thief what they want and chalk it up to a travel experience. about 6 years ago
As a solo female traveler there in September, I felt the streets to be fairly safe at night, but definitely stayed away from the smaller side streets in the Plaza de Armas area. The Miraflores & Barranca neighborhoods felt pretty safe at night, but I would echo what Jesse shared above. Cabs are cheap too, but look for ones with the radio taxi tel number on the roof vs.what may look like an unofficial cab driver. Be careful if watching a football match, the fans are zealous and can verge on rough, especially with foreigners, so keep a low profile. I would stay away from the Callau neighborhood at night. about 6 years ago