mapr-demos / python-bindings

Python bindings for MapR DB JSON API
Apache License 2.0
6 stars 15 forks source link

Does _get_java_object really work in document.py? #9

Closed tdunning closed 9 years ago

tdunning commented 9 years ago

It doesn't look to me like the underlying java object is every retained by the class when it is constructed.

If not, how would this class work?

On a related not, why is the dict created from the Java object? Couldn't all of the methods simply be replicated to make this object act like a dict, but not actually be one?

tdunning commented 9 years ago

I see that in python_to_java_cast that we depend on _get_java_object actually working.

jblazecybervision commented 9 years ago
  1. We don't always have java object at the point of creating Document, often we need to constuct it from dict. That's why we cannot just retain the java object because we don't have it simply often.
  2. Yes it really works. And was tested lively with VM. It works by creating a new java object and adding the fields from the saved dict.
  3. "Couldn't all of the methods simply be replicated to make this object act like a dict, but not actually be one?" It's pretty error-prone solution. There are a big bunch of magic methods inside dict. Why would you want to duplicate them all?
jblazecybervision commented 9 years ago

"On a related not, why is the dict created from the Java object? Couldn't all of the methods simply be replicated to make this object act like a dict, but not actually be one?"

Seems like the same topic is discussed in issue #10. I'll close this as duplicate, so our conversation doesn't split up in 2 different places.