[issue46173] float(x) with large x not raise OverflowError

2021-12-24 Thread Cyker Way
Cyker Way added the comment: Alright that helps. I guess I now understand what's happening here. Here are the two numbers in question: >>> M = int('1'*53+'0'*971, 2) >>> N = int('1'*53+'0'+'1'*970, 2) M is the largest number in binary64 range, while N is the largest

[issue46173] float(x) with large x not raise OverflowError

2021-12-24 Thread Cyker Way
Cyker Way added the comment: IEEE 754, 7.4 Overflow: > The overflow exception shall be signaled if and only if the destination > format’s largest finite number is exceeded in magnitude by what would have > been the rounded floating-point result (see 4) were the exponent range &g

[issue46173] float(x) with large x not raise OverflowError

2021-12-24 Thread Cyker Way
Cyker Way added the comment: If python's float strictly adheres to IEEE 754 binary64 (is that so?), then the problem may be caused by rounding. However, even in that case I still don't get the benefits of doing range check on a rounded input but not the input itself. Does IEEE 754 itself

[issue46173] float(x) with large x not raise OverflowError

2021-12-24 Thread Cyker Way
New submission from Cyker Way : Acccording to: https://docs.python.org/3/library/functions.html#float >If the argument is outside the range of a Python float, an OverflowError > will be raised. It is well known that the maximum value in IEEE 754 binary64 format is: >>>

[issue14074] argparse allows nargs>1 for positional arguments but doesn't allow metavar to be a tuple

2020-02-03 Thread Cyker Way
Cyker Way added the comment: Tuple support is documented: https://github.com/python/cpython/commit/98047eb806227f11212f6a42c242030a51964e30#diff-9c4a053d29149ba40370fb3e34faR1059 https://docs.python.org/3/library/argparse.html#metavar > Providing a tuple to ``metavar`` specif

[issue39145] Innocuous parent class changes multiple inheritance MRO

2019-12-28 Thread Cyker Way
Cyker Way added the comment: Ahhh, 1 second, I haven't really quit from this. I could open another thread but it's highly related to this one. I just came up with something that looks like a bug not a feature in the original c3. #!/usr/bin/env python3 #A C

[issue39145] Innocuous parent class changes multiple inheritance MRO

2019-12-28 Thread Cyker Way
Cyker Way added the comment: Thank you for the links. I doubt this c3 variant could break EPG consistency making it c2. May run some tests later and move on to discussion board. Guess I'm done here. -- ___ Python tracker <https://bugs.python.

[issue39145] Innocuous parent class changes multiple inheritance MRO

2019-12-27 Thread Cyker Way
Cyker Way added the comment: a typo: ...at this time we know we can extract X in (f1') because X is NOT in any tail... Missed the "NOT" in the previous text. -- ___ Python tracker <https://bugs.python.o

[issue39145] Innocuous parent class changes multiple inheritance MRO

2019-12-27 Thread Cyker Way
Cyker Way added the comment: Thanks for reply. It's not about the Python's implementation of C3 but C3 itself being used as the MRO algorithm in Python. It bites when you remove an independent interface from your class definition and its method calls become something else. I think I can

[issue39145] Innocuous parent class changes multiple inheritance MRO

2019-12-27 Thread Cyker Way
New submission from Cyker Way : With an inheritance graph like this: A C B D (X) A E Adding or removing class X in E's parents will change the order of A and C in E's MRO: EBDAC vs EBDCXA. I couldn't imagine what would be the "pe

[issue36294] `io.BufferedIOBase` returns `None`

2019-03-14 Thread Cyker Way
New submission from Cyker Way : Document of [BufferedIOBase](https://docs.python.org/3/library/io.html#io.BufferedIOBase) says: > ...unlike their RawIOBase counterparts, they will never return None. But this example shows the above statement is not true: import io import

[issue36293] Nonblocking read sys.stdin raises error

2019-03-14 Thread Cyker Way
New submission from Cyker Way : This piece of code will raise an error: import os import sys os.set_blocking(sys.stdin.fileno(), False) sys.stdin.read() Error: > TypeError: can't concat NoneType to bytes Not sure if this is relevant (for a different version of Pyt

[issue14074] argparse allows nargs>1 for positional arguments but doesn't allow metavar to be a tuple

2018-12-01 Thread Cyker Way
Cyker Way added the comment: Can confirm this bug still exists on master branch, python3.7, python3.6, and very likely other versions since it's reported. It seems only `_format_action_invocation` and `_get_action_name` need to be fixed. So we can do it more lightweight (<10 li

[issue35314] fnmatch failed with leading caret (^)

2018-11-26 Thread Cyker Way
Cyker Way added the comment: Thank you for confirmation. Knowing it is not fully POSIX-compliant helps with understanding. I'm asking this because I had interoperability issues writing python scripts providing shell-like utilities for filename expansion and the result may surprise users

[issue35314] fnmatch failed with leading caret (^)

2018-11-26 Thread Cyker Way
New submission from Cyker Way : In short, `fnmatch.fnmatch` doesn't match shell result. To test this, create a dir with 2 files: `a.py` and `b.py`. Then `ls [!b].py` and `ls [^b].py` will both show `a.py`. However, `fnmatch.fnmatch('a.py', '[!b].py')` returns `True` but `fnmatch.fnmatch

[issue35010] sort by partially reversed key tuple

2018-10-18 Thread Cyker Way
Cyker Way added the comment: Thank you very much for the great discussion here, especially Tim's great threads in *python-ideas* that give neat and insightful answers to this problem in different ways: - <https://mail.python.org/pipermail/python-ideas/2016-October/043045.html> -

[issue35010] sort by partially reversed key tuple

2018-10-17 Thread Cyker Way
Cyker Way added the comment: As for performance, I think both single-pass and multi-pass sorts have worst-case time complexity `m * n * log(n)`, assuming the number of items is `n` and each item has dimension `m`. Whichever is faster seems to be data-dependent. So I made a more

[issue35010] sort by partially reversed key tuple

2018-10-17 Thread Cyker Way
Cyker Way added the comment: Previous upload `example.py` was missing `__eq__`. Updated in `example-1.py`. -- Added file: https://bugs.python.org/file47876/example-1.py ___ Python tracker <https://bugs.python.org/issue35

[issue35010] sort by partially reversed key tuple

2018-10-17 Thread Cyker Way
Cyker Way added the comment: Multi-pass stable sorts should produce the correct result. But as the number of columns grow the code gets messy. For brevity this example only has 2 columns but it may be 10 or more in a real application. Furthermore, in some cases the application may need

[issue35010] sort by partially reversed key tuple

2018-10-17 Thread Cyker Way
New submission from Cyker Way : The current `sorted` function is somewhat limited and doesn't cover a use case that frequently occurs in real applications: sort by a tuple of keys where each key can be in asc or desc order. For example, you may have a list of site configs where each

[issue34296] Speed up python startup by pre-warming the vm

2018-08-08 Thread Cyker Way
Cyker Way added the comment: I'm fine with stdlib, 3rd party tools, or whatever. My focus is to understand is whether this idea can be correctly implemented on the python VM or not. I've been searching for similar implementations on standard JVM, but the results mostly come from research

[issue34296] Speed up python startup by pre-warming the vm

2018-08-07 Thread Cyker Way
Cyker Way added the comment: > While this issue is "pre warming VM", VM startup is not significant part of > your 500ms. 10-20ms should be OK for shell scripts. But a fork is still faster. > You're talking about application specific strategy now. It's differe

[issue34296] Speed up python startup by pre-warming the vm

2018-08-06 Thread Cyker Way
Cyker Way added the comment: It was tested on a x86_64 Linux system. The machine is not quite new but is OK for building and running python. The test script is actually a management tool for a larger project that is not released in public so I don't have right to disclose it here. When

[issue34296] Speed up python startup by pre-warming the vm

2018-08-06 Thread Cyker Way
Cyker Way added the comment: > VM startup + `import site` are done in 10~20ms on common Linux machine. > While Python VM startup is not lightning fast, library import time is much > slower than VM startup in many cases. In my tests, a helloworld python script generally takes ab

[issue34296] Speed up python startup by pre-warming the vm

2018-07-31 Thread Cyker Way
New submission from Cyker Way : I'm currently writing some shell tools with python3. While python can definitely do the job succinctly, there is one problem which made me feel I might have to switch to other languages or even pure bash scripts: python startup time. Shell tools are used very

[issue33210] pkgutil.walk_packages gives incomplete results

2018-04-04 Thread Cyker Way
Cyker Way <cyker...@gmail.com> added the comment: Update test program. -- Added file: https://bugs.python.org/file47519/test.py ___ Python tracker <rep...@bugs.python.org> <https://bugs.python

[issue33210] pkgutil.walk_packages gives incomplete results

2018-04-04 Thread Cyker Way
Change by Cyker Way <cyker...@gmail.com>: Removed file: https://bugs.python.org/file47516/test.py ___ Python tracker <rep...@bugs.python.org> <https://bugs.python

[issue33210] pkgutil.walk_packages gives incomplete results

2018-04-02 Thread Cyker Way
New submission from Cyker Way <cyker...@gmail.com>: The current implementation of `pkgutil.walk_packages()` is confusing. Users may be given incomplete results while no exception is raised if they don't explicitly provide the `prefix` parameter. The doc says: > prefix is a string

[issue29030] argparse: choices override metavar

2016-12-20 Thread Cyker Way
New submission from Cyker Way: Using `choices` option in `argparse` module caused unwanted behavior. # Without `choices` parser = argparse.ArgumentParser() parser.add_argument('length') parser.print_help() ## Output usage: demo.py [-h] length positional arguments