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

Suffix items #25

Open
pombredanne opened this issue Dec 14, 2015 · 7 comments
Open

Suffix items #25

pombredanne opened this issue Dec 14, 2015 · 7 comments

Comments

@pombredanne
Copy link

The suffixes method by @xmonader is great but it is missing returning items. It should also return items instead of just returning keys.

@superbobry
Copy link
Member

Do you mean you want suffix_items instead of suffixes?

@pombredanne
Copy link
Author

@superbobry exactly. Eventually with the iterator variants, in a way that's symmetric to the prefix* functions

@pombredanne
Copy link
Author

Sorry, I see now that I had written mumbo jumbo in my initial post...

@superbobry
Copy link
Member

Right. I think we should go this way and add suffix_items and suffix_values.

And while we're on it, why not revise the current prefix/suffix API? For instance, I think we should deprecate (and later drop) non-iterator methods (e.g. prefixes) in favour of iter_prefixes & friends. There's no point in keeping them, since you can always wrap the iter_* call into a list. Once we do this, I suggest to go further and remove the iter_* prefix to make the API is more Python3-ish.

@kmike what do you think?

@pombredanne
Copy link
Author

👍

@kmike
Copy link
Member

kmike commented Dec 14, 2015

In Python 3 keys() and alike methods don't just return iterators; they return key views which e.g. support membership checks, __repr__ and __str__ method which show values, len() method. AFAIK for custom objects you need to implement this logic yourselves; without it I found lists more convenient than iterators. That's why I went with non-iterator methods in first place - it was less work, more convenience for explorations in console, and there are iter_ methods for those who need memory-efficient production code.

@superbobry
Copy link
Member

This is a valid point. Anyway, I can sketch the view-based version of datrie in a separate branch and then we'll see if there's any benefit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants