Renamed `tempfilename` to `filename` for conciseness and clarity.
Replaced `==` and `!=` with `is` and `is not` when rhs is `None`.