|
|
|
|
|
by cbsmith
3401 days ago
|
|
> System calls in Linux are really fast. So saving "thousands" of system calls when /etc/localtime is in cache doesn't actually save that much actual CPU time. "fast" is a relative term, and is somewhat orthogonal to "efficient". There's a reason why certain functions use a vDSO. If you're just going to use a syscall anyway, there's kind of no point. |
|
> formatting dates and times
This shouldn't require a call to localtime; more explanation on the part of the article is required here. Breaking a seconds-since-epoch out into year/mo/day/etc. is "simple" math, and shouldn't require a filesystem access. Something else is amiss here.
> for everything from log messages
You're about to hit disk; a cache'd stat() isn't going to matter.
> to SQL queries.
You're about to hit the network; a cache'd stat() isn't going to matter.
(Now, I'm not saying you shouldn't set TZ; if it saves some syscalls, fine, and it might be the only sane value anyways.)
¹one of my old teams had an informal rule that any invocation of datetime.datetime.now() was a bug.