On Sun, Aug 30, 2020 at 7:28 AM Barry <ba...@barrys-emacs.org> wrote:
> How is it supposed to work with set or dict or other iterables without > clear order? > > see the discussion in another recent thread about making dict indexable -- which looks like it's not going to happen. so no -- this should not work with general iterables, indexes don't really make sense for iterables, only Sequences. Is your use of such a function so performance sensitive that you need this > in C? > Have you considered writing this as a C extension for your own use? > or use numpy :-) (which is probably where the name "argmin" came from, rather than "index_min") Signature: np.argmin(a, axis=None, out=None) Docstring: Returns the indices of the minimum values along an axis. Parameters ---------- a : array_like Input array. axis : int, optional By default, the index is into the flattened array, otherwise along the specified axis. out : array, optional If provided, the result will be inserted into this array. It should be of the appropriate shape and dtype. Returns ------- index_array : ndarray of ints Array of indices into the array. It has the same shape as `a.shape` with the dimension along `axis` removed The other question of course, is what to do when the minimum value appears more than once -- numpy appears to give the first occurance: In [6]: np.argmin([3,2,1,2,3,4,5,1,2,3]) Out[6]: 2 -CHB -- Christopher Barker, PhD Python Language Consulting - Teaching - Scientific Software Development - Desktop GUI and Web Development - wxPython, numpy, scipy, Cython
_______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/VUB7E7JIJ6O3LY2RC37XNEO6FJAR5SXH/ Code of Conduct: http://python.org/psf/codeofconduct/