Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Introducing Dictionaries Introducing Dictionaries What is a dictionary?

Erik Embervine
seal-mask
.a{fill-rule:evenodd;}techdegree
Erik Embervine
Python Development Techdegree Student 2,442 Points

what does it mean for a data structure to be "ordered"?

i ask because it seems python made some changes from version 3.6 to "keep track of the order in which items are added to a dictionary", whereas before that they were apparently not. i do understand that a list is indexed by numbers and dictionaries are indexed by keys. but the quiz that follows makes a distinction between dictionaries being "ordered" (quiz question 1) and how they are indexed (quiz question 2). so i'm just a little confused as to what makes a data structure "ordered" vs "not ordered".

thanks in advance,

1 Answer

Jeff Muday
MOD
Jeff Muday
Treehouse Moderator 28,717 Points

Wow! That is an amazing question. I'm glad you are thinking deeply about all this fits together. Good work!

Ordering varies according to the abstract data structure's goal set by the program designer. But the designer is working with data structures that are ultimately built on Python's native types.

Certain native types may be ordered by indices such as a list or not ordered like a dict. Just because a dict might appear to be ordered it is not guaranteed as such. It is how you iterate through a structure that is the question.

SQLAlchemy is a fine example of a library that achieves ordering by programmatic conditions and returns rich data structures that meet practical applications. The Pandas library offers rich data structures such as the DataFrame that will have varying orderings depending on the designer's choices. These are all built on numpy arrays and sequences and simple native data types but are abstracted to have iterators that produce contrived sequences.

I am not sure if I answered your question, but you are really showing your curiosity.