mseifert04 / iteration_utilities Goto Github PK
View Code? Open in Web Editor NEWUtilities based on Pythons iterators and generators.
Home Page: http://iteration-utilities.rtfd.io
License: Apache License 2.0
Utilities based on Pythons iterators and generators.
Home Page: http://iteration-utilities.rtfd.io
License: Apache License 2.0
Both share a lot of code and these could also support the eq
-parameter from split
.
The source tarball available on PyPI includes the test_*.py
files, but not conftest.py
, helper_cls.py
or helper_funcs.py
. This means the tests cannot be run from this tarball.
Two optional parameters if pred
is used:
check_for_False
(instead of True). Could be named truthy
or falsy
.return_predicate
(instead of the item return the pred(item)
.With getitem and getitem it's pretty useless now. However it's used in a lot of tests.
I expect this could be speed up using a C-function.
This would avoid unnecessary branching (checking for the presence of the argument) and allow for better optimization, especially if only positional arguments are allowed. Some examples are consume
and count_items
. I propose to split these into separate functions: consume
to advance
and consume
, and count_items
to count_items
, count_items
+ filter
, and count_items
+ filter_eq
.
assert(times > 0);
did not throw an Exception when times=0
was passed to grouper
.
Noticed in #34
This may need to be reworked in the other C functions that use assert
.
Generally check if the setup.cfg behaves as the setup.py did before
When installing with pyCharm:
https://pastebin.com/vGCEJNUY
With cmd and powerShell:
https://pastebin.com/5BX7761Y
With pip same error
See astropy/astropy#6658 (comment).
Would be nice if it would link to the source, but probably not so easy because a lot is written as C extension.
The tests for empty iterables were neglected in the memoryleak tests. These should be included!
As possible performance boost one could check the last position first in the bisect-helper function.
Why this may be faster:
current
is the next one to be yielded. The bisect is called every time the next item of the iterable from which the yielded item came from is to be inserted in current
.iterables
are somewhat consecutive the next item may be (with high probability) the next item to be yielded again.iterables
the normal bisect and the altered bisect will behave quite similar.iterables
doing one more comparison before starting the bisection will not slow it down unnecessary.These assumptions are somewhat debatable, I haven't tested it!
Some of the traverse methods aren't called and thus missing in the coverage. Maybe this can be added by gc.collect or such-like
For github actions
A remined of what to do:
pip install delocate
delocate-listdeps path_to_wheel
delocate-wheel -w target_dir path_to_wheel
Not sure if necessary, but better safe than sorry.
On aarch64, pip install iteration_utilities
builds the wheels from source code and then installs it. It requires the user to have a development environment installed on their system. Also, it takes more time to build the wheels than downloading and extracting the wheels from PyPI.
On aarch64, pip install iteration_utilities
should download the wheels from PyPI.
@MSeifert04, Please let me know your interest in releasing aarch64 wheels. I can help with this.
I modified this issue title to request support for Python 3.11 as well as (or instead of) 3.10. I also identify a workaround and an alternative package to iteration_utilities
below.
I understand that life gets in the way and projects can easily get pushed to the back-burner and eventually off the stove and into unmaintained status ๐ . In fact, your package still works fine as long as users have proper build tools installed. This is usually the case for users on Unix-like machines.
This can be a tall order for Windows users, who don't have build tools out of the box and must install them. Install Visual Build Tools 2022 (tick the box for C++ build tools and perform the ~7GB install), reboot, and you will be able to successfully pip install iteration-utilities
. This will also fix issues with packages which depend on iteration_utilities
.
There are a few ways to replace your dependency on iteration_utilities
if you wish to generalize your app to be easy to install for Windows and Unix-like users alike:
iteration_utilities
with something called funcy
(PyPI, repo, docs). They specifically needed deep flattening, which was a straight dependency swap. funcy
may not be feature-equal with iteration_utilities
, but it covers lots of the bases.iteration_utilities
's recommendations (see refs in the first paragraph) for possible substitutes to functions in iteration-utilities
, which may be able to satisfy your dependency.deepflatten
implementation found in the Copier issue above. https://github.com/wilsonwaters/copier/blob/b72bc87e74542d931369c77f7e27681737812181/copier/tools.py#L154-L169.iteration_utilities
and contributing them back to this project by getting in contact with the owner.Hello. Thank you for the latest bump to support Python 3.9. Are there plans to support Python 3.10 as well? At least one package (copier-org/copier) would benefit from this support.
Low Priority because there is heapq.merge
and sorted
Hi! First of all, thank you for your library.
I tried to install it using the pip command (pip install iteration-utilities
), however I had no success. The result can be found below.
I am new to Python, so I don't know exactly if this is something to do with the library or not, but it seems to be a library problem ("note: This is an issue with the package mentioned above, not pip."). Maybe this feedback can be useful for improvements.
ร Running setup.py install for iteration-utilities did not run successfully.
โ exit code: 1
โฐโ> [17 lines of output]
running install
C:\Users\Me\AppData\Local\Programs\Python\Python310\lib\site-packages\setuptools\command\install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
warnings.warn(
running build
running build_py
creating build
creating build\lib.win-amd64-cpython-310
creating build\lib.win-amd64-cpython-310\iteration_utilities
copying src\iteration_utilities\_additional_recipes.py -> build\lib.win-amd64-cpython-310\iteration_utilities
copying src\iteration_utilities\_classes.py -> build\lib.win-amd64-cpython-310\iteration_utilities
copying src\iteration_utilities\_convenience.py -> build\lib.win-amd64-cpython-310\iteration_utilities
copying src\iteration_utilities\_recipes.py -> build\lib.win-amd64-cpython-310\iteration_utilities
copying src\iteration_utilities\_utils.py -> build\lib.win-amd64-cpython-310\iteration_utilities
copying src\iteration_utilities\__init__.py -> build\lib.win-amd64-cpython-310\iteration_utilities
running build_ext
building 'iteration_utilities._iteration_utilities' extension
error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure
ร Encountered error while trying to install package.
โฐโ> iteration-utilities
note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.
By the way, I'm using Python 3.10.5 on Windows.
The constants in the _utils.py
module shouldn't be exposed in the package.
merge
is not yet pickleable.
PyArg_ParseTupleAndKeywords
does not increase the refcount of O
arguments: https://docs.python.org/3/c-api/arg.html#other-objects
Better check if there is any problem!
A few of the functions could use METH_FASTCALL
in Python 3.7+.
=================================== FAILURES ===================================
____________________________ test_recursive_pickle _____________________________
def test_recursive_pickle():
with AllowPickle():
f = partial(capture)
f.__setstate__((f, (), {}, {}))
try:
for proto in range(pickle.HIGHEST_PROTOCOL + 1):
with pytest.raises(RecursionError):
> pickle.dumps(f, proto)
tests/test_partial.py:87:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/Users/runner/hostedtoolcache/PyPy/3.5.3/x64/lib-python/3/pickle.py:1573: in _dumps
_Pickler(f, protocol, fix_imports=fix_imports).dump(obj)
/Users/runner/hostedtoolcache/PyPy/3.5.3/x64/lib-python/3/pickle.py:408: in dump
self.save(obj)
/Users/runner/hostedtoolcache/PyPy/3.5.3/x64/lib-python/3/pickle.py:520: in save
self.save_reduce(obj=obj, *rv)
/Users/runner/hostedtoolcache/PyPy/3.5.3/x64/lib-python/3/pickle.py:603: in save_reduce
save(args)
/Users/runner/hostedtoolcache/PyPy/3.5.3/x64/lib-python/3/pickle.py:475: in save
f(self, obj) # Call unbound method with explicit self
/Users/runner/hostedtoolcache/PyPy/3.5.3/x64/lib-python/3/pickle.py:729: in save_tuple
save(element)
/Users/runner/hostedtoolcache/PyPy/3.5.3/x64/lib-python/3/pickle.py:520: in save
self.save_reduce(obj=obj, *rv)
/Users/runner/hostedtoolcache/PyPy/3.5.3/x64/lib-python/3/pickle.py:603: in save_reduce
save(args)
/Users/runner/hostedtoolcache/PyPy/3.5.3/x64/lib-python/3/pickle.py:475: in save
f(self, obj) # Call unbound method with explicit self
/Users/runner/hostedtoolcache/PyPy/3.5.3/x64/lib-python/3/pickle.py:729: in save_tuple
save(element)
/Users/runner/hostedtoolcache/PyPy/3.5.3/x64/lib-python/3/pickle.py:520: in save
[...]
/Users/runner/hostedtoolcache/PyPy/3.5.3/x64/lib-python/3/pickle.py:729: in save_tuple
save(element)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <pickle._Pickler object at 0x0000000107794598>
obj = iteration_utilities.partial(<function capture at 0x00000001058bbe20>)
save_persistent_id = True
def save(self, obj, save_persistent_id=True):
self.framer.commit_frame()
# Check for persistent id (defined by a subclass)
pid = self.persistent_id(obj)
if pid is not None and save_persistent_id:
self.save_pers(pid)
return
# Check the memo
x = self.memo.get(id(obj))
if x is not None:
self.write(self.get(x[0]))
return
# Check the type dispatch table
t = type(obj)
f = self.dispatch.get(t)
if f is not None:
f(self, obj) # Call unbound method with explicit self
return
# Check private dispatch table if any, or else copyreg.dispatch_table
reduce = getattr(self, 'dispatch_table', dispatch_table).get(t)
if reduce is not None:
rv = reduce(obj)
else:
# Check for a class with a custom metaclass; treat as regular class
try:
issc = issubclass(t, type)
except TypeError: # t is not a class (old Boost; see SF #502085)
issc = False
if issc:
self.save_global(obj)
return
# Check for a __reduce_ex__ method, fall back to __reduce__
> reduce = getattr(obj, "__reduce_ex__", None)
E SystemError: <StackOverflow object at 0x103ccbf60>
/Users/runner/hostedtoolcache/PyPy/3.5.3/x64/lib-python/3/pickle.py:493: SystemError
To get the signature of a functools instance at runtime could be useful. Even if it probably won't work with inspect
.
Some time in the future.
pip reports the following warning on install.
DEPRECATION: iteration-utilities is being installed using the legacy 'setup.py install' method, because it does not have a 'pyproject.toml' and the 'wheel' package is not installed. pip 23.1 will enforce this behaviour change. A possible replacement is to enable the '--use-pep517' option. Discussion can be found at https://github.com/pypa/pip/issues/8559
It should be possible to:
iteration_utilities/src/alldistinct.c
Line 49 in 384948b
Call https://docs.python.org/3/c-api/exceptions.html#c.PyErr_Print to print the failure reason
In my script I wrote from iteration_utilities import duplicatess
in PyCharm (2019.1.4 Community) and see next error message ("Cannot find reference "duplicates" in init.py")
But code works fine.
All I want to know is it pure PyCharm bug or it can be somehow fixed in code?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.