wbolster / plyvel

Plyvel, a fast and feature-rich Python interface to LevelDB
https://plyvel.readthedocs.io/
Other
529 stars 75 forks source link

Why `DB.name` is not exposed? #88

Closed sbellem closed 5 years ago

sbellem commented 5 years ago

I just wonder why it is not possible to access the name of DB instance, e.g.:

>>> from plyvel import DB
>>> db = DB('/tmp/db', create_if_missing=True)
>>> db.name
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'plyvel._plyvel.DB' object has no attribute 'name'

I do not really know how cython works. I can see from the code that within the DB class self.name is accessible (e.g. in __repr__() and __str__()) so I wonder why we cannot access it when using it. Is this a design decision? Just curious.

Thanks!

wbolster commented 5 years ago

there's no particular reason. i think by default the attributes of cython classes are visible only at the C level (and not at the python level).

sbellem commented 5 years ago

Ok thanks!

I made a tiny PR: #90 that exposes it.

I can put more work into the PR if needed.

wbolster commented 5 years ago

closed via #90