always use os.getenv/os.putenv
refactor the _memoize pattern