Why don't you just return os.environ instead of copying it. Not to mention that there are functions to copy objects that you can import...