YAML.dump(obj, f)?

Would anyone besides me appreciate a YAML.dump method, analogous with
Marshal.dump, which takes two args, an object and a File?

Besides bringing the interface into line with Marshal, this would avoid
generating an intermediate string, as in

f.write(object.to_yaml)

I’m just thinking about GC frequency, not functionality…

Note that you can already do

object = YAML.load(f)

(I’m not sure whether it generates an intermediate string.) So having
dump as well would be kinda natural.

While we’re comparing Marshal and YAML, does anyone know if there are
any object types that one handles but the other doesn’t? Are they
equivalent, as far as what they can serialize?

I’ve been very impressed at how well YAML treats Ruby data, but maybe
there’s a gotcha somewhere…

Would anyone besides me appreciate a YAML.dump method, analogous with
Marshal.dump, which takes two args, an object and a File?

Yes, I think so. I was just looking at Marshal the other day and
thinking identically. You’ll see this in 0.49.3 this weekend.

While we’re comparing Marshal and YAML, does anyone know if there are
any object types that one handles but the other doesn’t? Are they
equivalent, as far as what they can serialize?

From what I can see of the Marshal.c source, YAML is pretty close. And
what YAML can’t dump, you can teach it to (both dump and load, that is).

_why

···

Joel VanderWerf (vjoel@PATH.Berkeley.EDU) wrote: