Issue #17685 has been updated by mrkn (Kenta Murata).


You cannot get the original object from `Marshal.load`.  This is `Marshal.load`'s nature.
`Marshal.load` always creates a new object (the different object from the original one).
`Object#equal?` compares object identities, so `b.equal? new_b` is always false.

----------------------------------------
Feature #17685: Marshal format for out of band buffer objects
https://bugs.ruby-lang.org/issues/17685#change-90942

* Author: dsisnero (Dominic Sisneros)
* Status: Open
* Priority: Normal
----------------------------------------
Allow the use of the marshal protocol to transmit large data (objects) from one process or ractor to another, on same machine or multiple machines without extra memory copies of the data.

See Python PEP 574 - https://www.python.org/dev/peps/pep-0574/ Pickle protocol with out of band data.

When marshalling memoryview objects, it would be nice to be able to use zero copy loads of the memoryviews. That way when loading the file we can use that memoryview without copying it also if desired.

Add a Marshal::Buffer type in new version of Marshal to represent something that indicates a serializable no-copy buffer view.

The marshal_dump must be able to represent references to a Marshal::Buffer to indicate that the loader might get the actual buffer out of band

The marshal_load must be able to provide the Marshal::Buffer for deserialization

Marshal load and dump should work normally if not used out of band.

```ruby
class Apache::Arrow
  
  def marshal_dump(*)
     if marshal.version > '0.4'
         Marshal::Buffer.new(self)
     else
        #normal dump
     end
  end
end
```




-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>