Conversation
Not exactly sure, why I decided using "del" wouldn't be good enough, but having the option of an easier interface is no bad thing. It is an open question if we should allow read/put on module and on class level or hide the class methods.
|
That part of the interface is similar to how it works on https://github.com/sebastinas/python-libdiscid. There is no reason this wouldn't work with ctypes. |
|
Funny to see this today, see what I did yesterday to the Ruby version: phw/ruby-discid@4b8e623 (wanted to do that refactoring for a long time, guess I'll release that as a 1.0). I like that simplification for the python bindings, too. It feels more like a Python module and less like a Java one that way. |
|
Yes, I've seen your changes and that reminded me I wanted to push a branch with this change. Still a lot of things to test and change (all the tests, documentation decisions etc.), but it seems people want this simplification. |
|
Test program: import discid
first = 1
last = 15
offsets = [258725, 150, 17510, 33275, 45910,
57805, 78310, 94650,109580, 132010,
149160, 165115, 177710, 203325, 215555, 235590]
disc_object = discid.DiscId()
def put_object():
disc_object.put(first, last, offsets)
#disc_object.id
def put_module():
disc = discid.put(first, last, offsets)
#disc.id
for i in range(0, 1000000):
#put_module()
put_object()1 million put()s. Tried with module and class level put, with and without generating a disc id. |
|
I removed the If you try to calculate 1 M disc IDs, you normally would have some file system access anyways, which is probably slower than the whole discid operation. FYI: conclusion: |
These should now be used to create DiscID objects, rather than creating them directly.
This also means the DiscId() object is not mentioned in code directly anymore.
|
Since I technically still use |
Not exactly sure, why I decided using "del" wouldn't be good
enough, but having the option of an easier interface is no bad thing.
It is an open question if we should allow read/put on module and on
class level or hide the class methods.
Re-using the same class for multiple put()s is in theory faster, but not sure if that is relevant with the overhead the binding introduces.
Even when we decide to hide read/put on class level, we might just keep them for now, mark them as deprecated and remove them from documentation.