Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

various python enhancements #2207

Open
markus2330 opened this Issue Aug 24, 2018 · 0 comments

Comments

Projects
None yet
2 participants
@markus2330
Copy link
Contributor

markus2330 commented Aug 24, 2018

Some small nice to have for Python:

k==None comparison after lookup does not work.

   ks = kdb.KeySet()
   ks.append (kdb.Key("user/something"))
   k = ks.lookup("user/something")
   if k == None:
   	pass

expected outcome: k is not None, so "pass" should not be executed but the program should continue afterwards (it works if k != None)

actual outcome: exception ValueError: invalid null reference in method 'Key___eq__', argument 2 of type 'kdb::Key const &'

workaround: use key is None which is arguably the correct thing to do anyway

KeySet not printed

expected outcome: print key by key, similar to built-in data structures in Python
actual outcome:

<kdb.KeySet; proxy of <Swig Object of type 'kdb::KeySet *' at 0x7f05b3eb4db0> >

workaround: write loop for k in ks: print k,

Add key objects to hashmap

before c88d0b0 it was not possible. Now it is possible but it might be buggy because users might change the name after adding the key to a hashmap. To avoid this, the readonly flag should be set. Maybe we even need a FrozenKey?

workaround: use the KeySet, which soon is a hashmap on lookups anyway

No len(key)

>>> import kdb
>>> key = kdb.Key("user/hello/sub")
>>> len(key)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: object of type 'Key' has no len()

Expected behavior: return 3

workaround:

sum (1 for _ in key)

@markus2330 markus2330 removed their assignment Nov 17, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.