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


The object identity in Ruby is defined by the value of `object_id`. `Object#equal?` just compares the value of `object_id`.
No more than one object has the same value of `object_id.`

Marshal cannot generate an object whose `equal?` returns true for the other object because no more than one objects have the same value of `object_id`.

What is the reason why you stick to `equal?` method and Marshal combination?  Doesn't `==` work well for your purpose?

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

* 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>