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

Optionally based on OrderedDict #57

Closed
joslarson opened this issue Apr 27, 2016 · 3 comments
Closed

Optionally based on OrderedDict #57

joslarson opened this issue Apr 27, 2016 · 3 comments

Comments

@joslarson
Copy link

joslarson commented Apr 27, 2016

I'm thinking it would be nice to be able to use this with OrderedDict, such that the order things were put into the dict is the same order they come out when dumped to json for an api endpoint.

Maybe something like the following where

import json
from addict import Dict
...
response = Dict(ordered=True)
response.count = len(results)
response.next = next_url
response.prev = prev_url
response.results = results

print(json.dumps(response))

prints the following in order:

{
    "count": 435,
    "next": "/.../?page=2",
    "prev": null,
    "results": [
        ...
    ]
}

Thoughts?

@mewwts
Copy link
Owner

mewwts commented May 5, 2016

Hey, @joslarson. Thanks for reaching out!

It's been a while since I actively maintained this project, but I'd like to get on the horse again. I'm thinking of how to make this the most flexible. The current implementation makes it a bit of an hassle to make this kind of stuff possible.

Do you have any ideas on how to make such a change?

I'll schedule some time soon to have a look Addict.

Cheers 😊

@joslarson
Copy link
Author

Thanks for the response, I'm definitely willing to help out, but I haven't dug into the source yet as I wanted to talk about it at a conceptual level first. Since posting this I've been thinking that with this project it might make more sense to just base it on OrderedDict by default. I'm not sure if the OrderedDict is less performant or not, but I don't think that should matter in a library whose goal is to make the ultimate flexible dictionary. I'm not even convinced you'd need to have the option for an unordered base.

@mewwts
Copy link
Owner

mewwts commented Jul 15, 2016

Hi @joslarson, I've decided to close this as I've decided to keep the module leaner instead of adding more functionality. 🎱

@mewwts mewwts closed this as completed Jul 15, 2016
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

2 participants