PyYaml?

Andrew Dalke adalke at mindspring.com
Sat Sep 18 12:28:54 EDT 2004


Chris S. wrote:
> However, Pickle's small programming language 
> allows for arbitrary file deletion. That would not be possible with Yaml.

I just looked through pickle.py's list of opcodes.  I don't
see any which mention file deletion.

There are ones that let you call an arbitrary callable
with arbitrary parameters, like 'os.unlink' with your filename
of choice.  But even if you limited that to arbitrary constructors,
instead of all arbitrary callables, you can still delete files.
Consider tempfile._TemporaryFileWrapper.  Except under MS Windows,
if you make one of these its __del__ deletes the named files.
You can pass any name you want as the filename, so it provides
a way to delete files via pickle.

If Yaml lets me create
    tempfile._TemporaryFileWrapper(None, "/path/to/file")
then that file will (eventually) be deleted.

If Yaml doesn't let me create that file then either 1) it
isn't as powerful as pickle or 2) it uses some registery
of allowed object.  If #2, I think pickle support that too.


>> Also, I'll guess that it doesn't handle Python's new __slots__
>> since it only mentions __dict__.
> 
> True. In fact, the current implementation doesn't yet fully handle 
> subclassing/inheritance. They've done a lot, but it's still a work in 
> progress.

Then why would be it a viable replacement for pickle?

				Andrew
				dalke at dalkescientific.com



More information about the Python-list mailing list