Molecule.to_file() should support file-like objects
Is your feature request related to a problem? Please describe. Currently, writing many molecules to a file requires (1) conversion to JSON as a string, then (2) writing the string to a file.
Describe the solution you'd like
Molecule supports the from_file() method, but its argument currently only accepts filename strings. Adding support for file-like objects would make it much more flexible in being able to flush its serialized contents to a file that is already open, or gzipped, etc.
Describe alternatives you've considered This would purely be a convenience feature.
Writing many molecules to a JSON file should involve getting the dictionary form of the molecule, appending to a dict or list, and writing the JSON once. Continuous JSON appending doesn’t make sense as it cannot be read back in easily.
We currently do not have any stream based formats so continuous appending would prevent multi molecule reading. I might be misunderstanding, can you provide a small use case snippet.