[issue47114] random.choice and random.choices have different distributions

2022-03-24 Thread Mark Bell
Mark Bell added the comment: To give two more consequences of `random.choices` using floating point arithmetic: 1) When doing `random.choices([A, B, C], weights=[2**55, 1, 1])` the cumulative weight to bisect for is selected using `floor(random() * (2**55 + 1 + 1 + 0.0))`. Since

[issue47114] random.choice and random.choices have different distributions

2022-03-24 Thread Mark Bell
New submission from Mark Bell : The docstring for `random.choices` indicates that ``` import random random.choices(population, k=1) ``` should produce a list containing one item, where each item of `population` has equal likelihood of being selected. However `random.choices` draws elements

[issue28937] str.split(): allow removing empty strings (when sep is not None)

2021-06-05 Thread Mark Bell
Mark Bell added the comment: > Instead, the discussion was focused on removing *all* empty strings from the > result. I imagine that the discussion focussed on this since this is precisely what happens when sep=None. For example, 'a b c ​'.split() == ['a', 'b', 'c']. I

[issue28937] str.split(): allow removing empty strings (when sep is not None)

2021-06-05 Thread Mark Bell
Mark Bell added the comment: Andrei: That is a very interesting observation, thank you for pointing it out. I guess your example / argument also currently applies to whitespace separation too. For example, if we have a whitespace separated string with contents: col1 col2 col3 a b c x y z

[issue28937] str.split(): allow removing empty strings (when sep is not None)

2021-05-20 Thread Mark Bell
Mark Bell added the comment: Thank you very much for confirming these test cases. Using these I believe that I have now been able to complete a patch that would implement this feature. The PR is available at https://github.com/python/cpython/pull/26222. As I am a first-time contributor

[issue28937] str.split(): allow removing empty strings (when sep is not None)

2021-05-18 Thread Mark Bell
Change by Mark Bell : -- pull_requests: +24839 pull_request: https://github.com/python/cpython/pull/26222 ___ Python tracker <https://bugs.python.org/issue28

[issue28937] str.split(): allow removing empty strings (when sep is not None)

2021-05-18 Thread Mark Bell
Mark Bell added the comment: So I think I agree with you about the difference between .split() and .split(' '). However wouldn't that mean that ' x y z'.split(maxsplit=1, keepempty=False) == ['x', 'y z'] since it should do one split

[issue28937] str.split(): allow removing empty strings (when sep is not None)

2021-05-18 Thread Mark Bell
Mark Bell added the comment: > suggests that empty strings don't count towards maxsplit Thank you for the confirmation. Although just to clarify I guess you really mean "empty strings *that are dropped from the output* don't count towards maxsplit". Just to double check thi

[issue28937] str.split(): allow removing empty strings (when sep is not None)

2021-05-18 Thread Mark Bell
Mark Bell added the comment: So I have taken a look at the original patch that was provided and I have been able to update it so that it is compatible with the current release. I have also flipped the logic in the wrapping functions so that they take a `keepempty` flag (which is the opposite

[issue39755] Change example of itertools.product

2020-02-25 Thread Mark Bell
New submission from Mark Bell : The documentation for itertools.product at: https://docs.python.org/3/library/itertools.html#itertools.product currently says that: For example, product(A, B) returns the same as ((x,y) for x in A for y in B) While this is broadly correct, since product

[issue31141] Start should be a keyword argument of the built-in sum

2017-08-16 Thread Mark Bell
Mark Bell added the comment: I ran some timing tests of the patch I submitted to compare it to the current build of Python. Using timit on the current master branch I got: python.exe -m timeit "sum(())" 1.12 usec per loop python.exe -m timeit "sum((), 0)"

[issue31141] Start should be a keyword argument of the built-in sum

2017-08-08 Thread Mark Bell
Changes by Mark Bell <mark00b...@googlemail.com>: -- type: -> behavior ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue31141> ___ _

[issue31141] Start should be a keyword argument of the built-in sum

2017-08-08 Thread Mark Bell
New submission from Mark Bell: The built-in function sum takes an optional argument "start" to specify what value to start adding from (defaults to 0). This argument should be a keyword argument in order to match the other built-in functions such as: enumerate(range(10

[issue21810] SIGSEGV in PyObject_Malloc when ARENAS_USE_MMAP

2014-06-19 Thread John-Mark Bell
New submission from John-Mark Bell: In low-memory scenarios, the Python 2.7 interpreter may crash as a result of failing to correctly check the return value from mmap in new_arena(). This changeset appears to be the point at which this issue was introduced: http://hg.python.org/cpython/rev

[issue21757] Can't reenable menus in Tkinter on Mac

2014-06-14 Thread Mark Bell
New submission from Mark Bell: The following example is a Tkinter app with a button that toggles the menu being enabled based off of https://mail.python.org/pipermail/tkinter-discuss/2004-September/000204.html #--- from Tkinter import * root=Tk() def hello