question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Move odict and oset code to build/inline_copy/

See original GitHub issue

Currently there are quite a few unconditional uses of nuitka.containers.odict.

Builtins.py:from nuitka.containers.odict import OrderedDict
build/inline_copy/lib/scons-2.3.2/SCons/Executor.py:        for odict in self.overridelist:
build/inline_copy/lib/scons-2.3.2/SCons/Executor.py:            overrides.update(odict)
build/inline_copy/lib/scons-3.1.2/SCons/Executor.py:        for odict in self.overridelist:
build/inline_copy/lib/scons-3.1.2/SCons/Executor.py:            overrides.update(odict)
codegen/Reports.py:from nuitka.containers.odict import OrderedDict
containers/odict.py:It is not in 2.6, for this version we are using the odict.py as mentioned in the
freezer/Standalone.py:from nuitka.containers.odict import OrderedDict
nodes/LocalsScopes.py:from nuitka.containers.odict import OrderedDict
plugins/Plugins.py:from nuitka.containers.odict import OrderedDict

oset.py is similar.

On Python 2.7+, the code in nuitka.containers.odict is ignored, except for imports from stdlib/builtins.

As this module is under the “Python-2.0” SPDX license, and rightly has no Apache-2.0 header, it is desirable to not include it in distro packages unless necessary. Its inclusion means the Nuitka package should use “License: Apache-2.0 AND Python-2.0” which is likely unnecessarily complications and confusion to wary users.

It can still be in the source tree, ideally under build/inline_copy, so it is easier to remove it.

The oset code should also be moved into build/inline_copy/ . It might be possible to inline https://pypi.org/project/oset/ , thereby making it easier to patch in the python package if present. That packages repo has disappeared - need to check its other metadata to see if it appropriately credits the original authors. (its setup.py uses maintainer=... but not author=... http://code.activestate.com/recipes/576694/ is MIT. Now we need “License: Apache-2.0 AND Python-2.0 AND MIT”. Ugh.

And I notice inside oset.py

# Note: Kay Hayen did some changes for Nuitka keeping this license. These
# changes are not improvements, use the original source instead, not this
# file.

Another alternative is to use one of the many other better-maintained ordered set libraries.

I’m about to do a build with the following so that I dont need to change the License:...

echo 'from collections import OrderedDict' > nuitka/containers/odict.py
echo 'from ordered_set import OrderedSet' > nuitka/containers/oset.py

I expect this to break … 😉

A code search reveals to other licenses in use

build/include/nuitka/hedley.h: * SPDX-License-Identifier: CC0-1.0
build/include/nuitka/incbin.h:For more information, please refer to <http://unlicense.org/>

Those files also have the Apache-2.0 header, so are being dual-licensed as Apache-2.0, and that is legally sound and appropriate to do in this case, and means these two files are not problematic.

Are there any other bits of inlined code in the codebase?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:17 (17 by maintainers)

github_iconTop GitHub Comments

1reaction
kayhayencommented, Jan 31, 2021

The first one, does the wrong trade of, citing their desc:

Hettiger's implementation kept its content in a doubly-linked list referenced by a dict. As a result, looking up an item by its index was an O(N) operation, while deletion was O(1).

This version makes different trade-offs for the sake of efficient lookups. Its content is a standard Python list instead of a doubly-linked list. This provides O(1) lookups by index at the expense of O(N) deletion, as well as slightly faster iteration.

Since I am doing deletions, I highly disapprove of that.

The second one is using Cython, which I approve of and is Python2 compatible as well, which is something I need. I would welcome a PR that makes optional use of it. It might make some things in Nuitka compile time faster.

1reaction
jayvdbcommented, Jan 30, 2021

https://pypi.org/project/ordered-set/ and https://pypi.org/project/orderedset/ passed all of the test suite. I guess that is sufficient to use it. If you are aware of the parts of Nuitka using oset which dont have test coverage, I should manually test them.

boltons works:

echo ‘from boltons.setutils import IndexedSet as OrderedSet’ > nuitka/containers/oset.py

extended-collections works:

echo ‘from collections_extended import setlist as OrderedSet’ > nuitka/containers/oset.py

sortedcollections isnt usable due to https://github.com/grantjenks/python-sortedcollections/issues/17 , and oset has the same problem.

ordered-hash-set fails with:

ordered_hash_set.py", line 19, in add
  if item not in self._items.keys():
TypeError: unhashable type: 'list'

nr.collections fails with AttributeError: 'OrderedSet' object has no attribute 'index'

Read more comments on GitHub >

github_iconTop Results From Across the Web

No results found

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found