Skip to content

Use dict instead of OrderedDict since dict is ordered by default from Python 3.6 - #4145

Merged
jarrodmillman merged 1 commit into
networkx:masterfrom
tirkarthi:improve-perf
Aug 11, 2020
Merged

jarrodmillman merged 1 commit into
networkx:masterfrom
tirkarthi:improve-perf

Conversation

@tirkarthi

Copy link
Copy Markdown
Contributor

Fixes #4143

@dschult dschult added this to the networkx-2.5 milestone Aug 10, 2020

@rossbar rossbar left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are still some differences between OrderedDict and 3.6+ dictionaries (though they are indeed ordered by default). For example, the comparison operators are sensitive to order in OrderedDict, but not in dict:

>>> from collections import OrderedDict
>>> d1 = {1: '1', 2: '2'}
>>> d2 = {2: '2', 1: '1'}
>>> d1 == d2
True
>>> OrderedDict(d1) == OrderedDict(d2)
False

AFAICT the affected code (i.e. _all_simple_paths_graph and _all_simple_paths_multigraph) don't depend on these properties, so the changes here LGTM; I just wanted to point it out!

@jarrodmillman
jarrodmillman merged commit 877ce7d into networkx:master Aug 11, 2020
@tirkarthi

Copy link
Copy Markdown
Contributor Author

Thanks @dschult and @rossbar.

jarrodmillman added a commit to mbruhns/networkx that referenced this pull request Aug 11, 2020
* upstream/master:
  Update apt-get on circleci image (networkx#4147)
  MAINT: fixups to parse_edgelist. (networkx#4128)
  Use dict instead of OrderedDict since dict is ordered by default from Python 3.6. (networkx#4145)
  MAINT: Switch to abc-based isinstance checks in to_networkx_graph (networkx#4136)
  Add tree isomorphism (networkx#4067)
  Updated draw_networkx to accept numpy array for edgelist (networkx#4132)
  CI: temporary fix for CI latex installation issues (networkx#4131)
  Fix parse_edgelist behavior with multiple attributes (networkx#4125)
MridulS pushed a commit to MridulS/networkx that referenced this pull request Feb 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

Replace OrderedDict with dict in simple_paths module

4 participants