[issue38438] argparse "usage" overly-complex with nargs="*"
Nick Timkovich added the comment: The `[arg [arg ...]]` feels a bit more formal to me, and I might prefer it in the example shown where the arg name is fairly short. That said, `man mv` shows something like: mv [OPTION]... [-T] SOURCE DEST mv [OPTION]... SOURCE... DIRECTORY mv [OPTION]... -t DIRECTORY SOURCE... -- nosy: +nicktimko ___ Python tracker <https://bugs.python.org/issue38438> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue38046] Can't use sort_keys in json.dumps with mismatched types
Change by Nick Timkovich : -- components: +Library (Lib) title: JSON sorting type error -> Can't use sort_keys in json.dumps with mismatched types versions: +Python 3.9 -Python 3.7 ___ Python tracker <https://bugs.python.org/issue38046> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue38046] JSON sorting type error
Nick Timkovich added the comment: It's not clear what you suggest, but it is likely better to alert the user that their keys have mismatched types than to suppress it by default. Perhaps alongside the `sort_keys` argument, you would like a parameter that gets passed into `sorted()` when the items are sorted? Perhaps an additional argument, or if sort_keys is a callable, use that as the `key` argument to sorted? ``` strange = {"1":"one", 2:"ii"} json.dumps(strange, sort_keys=True, key=str) json.dumps(strange, sort_keys=str) # {"1": "one", 2: "ii"} ``` -- nosy: +nicktimko ___ Python tracker <https://bugs.python.org/issue38046> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue37968] Add a turtle module function to draw a circle centered at the turtle
Nick Timkovich added the comment: To clarify, there is an "ARC" command in Logo that draws a circle/circle segment *centered on* the turtle. Reference: http://fmslogo.sourceforge.net/manual/command-arc.html Examples: https://personal.utdallas.edu/~veerasam/logo/ That command is not/has not been implemented in Python's turtle graphics. As Eric mentioned, it could be considered a benefit as the principle of turtle graphics is that turtles have no arms to move the pen away from their body (adolescent abnormal assassin turtles, notwithstanding). -- ___ Python tracker <https://bugs.python.org/issue37968> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue37969] urllib.parse functions reporting false equivalent URIs
Nick Timkovich added the comment: Looking at the history, the line in the docs used to say > ... (for example, an empty query (the draft states that these are equivalent). which was changed to "the RFC" in April 2006 https://github.com/python/cpython/commit/ad5177cf8da#diff-5b4cef771c997754f9e2feeae11d3b1eL68-R95 The original language was added in February 1995 https://github.com/python/cpython/commit/a12ef9433baf#diff-5b4cef771c997754f9e2feeae11d3b1eR48-R51 So "the draft" probably meant the draft of RFC-1738 https://tools.ietf.org/html/rfc1738#section-3.3 which is kinda vague on it. It didn't help that rewording it as "the RFC" later when there are 3+ RFCs referenced in the lib docs, one of which obsoleted the another RFC and definitely changed the meaning of the loose "?". The draft of 2396 always seemed to have the opposite wording you point out, at least back in draft 07 (September 2004): https://tools.ietf.org/html/draft-fielding-uri-rfc2396bis-07#section-6.2.3 The draft 06 (April 2004) was silent on the matter https://tools.ietf.org/html/draft-fielding-uri-rfc2396bis-06#section-6.2.3 -- nosy: +nicktimko ___ Python tracker <https://bugs.python.org/issue37969> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue37968] The turtle
Nick Timkovich added the comment: Resolving #1 as you suggest is next to impossible. Python can not deduce if you meant to call the function or just refer to its name. Admittedly, the latter is strange in non-interactive contexts, but it is valid. #2, as far as I can tell Logo had an ARC command: ARC angle radius draws an arc of a circle, with the turtle at the center, with the specified radius, starting at the turtle's heading and extending clockwise through the specified angle. The turtle does not move. I guess I don't know the history about why there's turtle.circle in Python which *does* move the turtle, and has the center *not* at the turtle. Adding an equivalent "turtle.arc" function might be useful, though the naming would be a bit confusing. Can you propose a better name and define exactly how it would work? -- ___ Python tracker <https://bugs.python.org/issue37968> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue37968] The turtle
Nick Timkovich added the comment: Regarding #1: In Python, you may refer to a variable's name (e.g. `rt`, which is a function), which often has no effect in a script. In the REPL (where you see >>>) it is useful to inspect the object: >>> turtle.rt In order to call that name/function, parentheses are *required* unlike other languages where they are optional (Ruby). So, you don't get an error message, but one is not expected. Linting tools can alert you to statements that don't appear to have an effect. Regarding #2: Students of the turtle could create a reusable function to draw a circle with the turtle and return to the starting position. It would be an excellent exercise with multiple solutions! -- nosy: +nicktimko ___ Python tracker <https://bugs.python.org/issue37968> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue26834] Add truncated SHA512/224 and SHA512/256
Nick Timkovich <prometheus...@gmail.com> added the comment: Was this patch mostly ready to go? The additional SHA512 variants are appealing because they run ~40% faster than SHA256 on 64-bit hardware for longer messages. -- nosy: +nicktimko ___ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue26834> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue27337] 3.6.0a2 tarball has weird paths
Nick Timkovich added the comment: In pyenv this was "fixed" by pointing to the .tar.xz archive instead of the .tgz https://github.com/yyuu/pyenv/pull/652, maybe you could implement that for Pythonz? -- nosy: +nicktimko -ned.deily, petere ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue27337> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20820] HTML being escaped on some release pages
New submission from Nick Timkovich: On a random trip through Python's past I noticed the new site is escaping HTML on some older version release notes: * http://www.python.org/download/releases/1.6/ * http://www.python.org/download/releases/2.0/ * http://www.python.org/download/releases/2.1/ * http://www.python.org/download/releases/2.1.[1-3]/ (2.1.1, 2.1.2, 2.1.3) * http://www.python.org/download/releases/2.2/ * http://www.python.org/download/releases/2.2.[1-2]/ * http://www.python.org/download/releases/2.3/ * http://www.python.org/download/releases/2.3.[1-5]/ I was pointed here from the pydotorg-www list, but None of the components seem to fit with website maintenance. -- messages: 212531 nosy: nicktimko priority: normal severity: normal status: open title: HTML being escaped on some release pages type: behavior ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20820 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Re: Tuples and immutability
On Thu, Feb 27, 2014 at 10:33 AM, Chris Angelico ros...@gmail.com wrote: On Fri, Feb 28, 2014 at 3:27 AM, Eric Jacoboni eric.jacob...@gmail.com wrote: But, imho, it's far from being a intuitive result, to say the least. It's unintuitive, but it's a consequence of the way += is defined. If you don't want assignment, don't use assignment :) ChrisA Where is `.__iadd__()` called outside of `list += X`? If the only difference from `.extend()` is that it returns `self`, but the list was already modified anyway, why bother with reassignment? -- https://mail.python.org/mailman/listinfo/python-list
Re: intersection, union, difference, symmetric difference for dictionaries
On Tue, Feb 25, 2014 at 2:32 PM, mauro ma...@gmail.com wrote: So I wonder why operations such us intersection, union, difference, symmetric difference that are available for sets and are not available for dictionaries without going via key dictviews. How would the set operations apply to the dictionary values? -- https://mail.python.org/mailman/listinfo/python-list
[issue20693] Sidebar scrolls down 2x as fast as page content
New submission from Nick Timkovich: When scrolling down in the Python 3.4 docs (e.g. http://docs.python.org/3.4/library/index.html ) the Sphinx sidebar's top value increases twice as fast as the user moves down the page, resulting in it running away. I don't know sufficient JS to identify the problem, but I'm guessing it's somewhere in the sidebar.js:scroll_sidebar() function or whatever might configure it. (apologies, I *think* I may have sent a similar mail to the docs list already) -- assignee: docs@python components: Documentation files: py34sidebar.png messages: 211675 nosy: docs@python, nicktimko priority: normal severity: normal status: open title: Sidebar scrolls down 2x as fast as page content type: behavior versions: Python 3.4 Added file: http://bugs.python.org/file34149/py34sidebar.png ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20693 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Generator using item[n-1] + item[n] memory
I have a Python 3.x program that processes several large text files that contain sizeable arrays of data that can occasionally brush up against the memory limit of my puny workstation. From some basic memory profiling, it seems like when using the generator, the memory usage of my script balloons to hold consecutive elements, using up to twice the memory I expect. I made a simple, stand alone example to test the generator and I get similar results in Python 2.7, 3.3, and 3.4. My test code follows, `memory_usage()` is a modifed version of [this function from an SO question](http://stackoverflow.com/a/898406/194586) which uses `/proc/self/status` and agrees with `top` as I watch it. `resource` is probably a more cross-platform method: ### import sys, resource, gc, time def biggen(): sizes = 1, 1, 10, 1, 1, 10, 10, 1, 1, 10, 10, 20, 1, 1, 20, 20, 1, 1 for size in sizes: data = [1] * int(size * 1e6) #time.sleep(1) yield data def consumer(): for data in biggen(): rusage = resource.getrusage(resource.RUSAGE_SELF) peak_mb = rusage.ru_maxrss/1024.0 print('Peak: {0:6.1f} MB, Data Len: {1:6.1f} M'.format( peak_mb, len(data)/1e6)) #print(memory_usage()) data = None # go del data # away gc.collect() # please. # def memory_usage(): # Memory usage of the current process, requires /proc/self/status # # http://stackoverflow.com/a/898406/194586 # result = {'peak': 0, 'rss': 0} # for line in open('/proc/self/status'): # parts = line.split() # key = parts[0][2:-1].lower() # if key in result: # result[key] = int(parts[1])/1024.0 # return 'Peak: {peak:6.1f} MB, Current: {rss:6.1f} MB'.format(**result) print(sys.version) consumer() ### In practice I'll process data coming from such a generator loop, saving just what I need, then discard it. When I run the above script, and two large elements come in series (the data size can be highly variable), it seems like Python computes the next before freeing the previous, leading to up to double the memory usage. $ python genmem.py 2.7.3 (default, Sep 26 2013, 20:08:41) [GCC 4.6.3] Peak:7.9 MB, Data Len:1.0 M Peak: 11.5 MB, Data Len:1.0 M Peak: 45.8 MB, Data Len: 10.0 M Peak: 45.9 MB, Data Len:1.0 M Peak: 45.9 MB, Data Len:1.0 M Peak: 45.9 MB, Data Len: 10.0 M #^^ not much different versus previous 10M-list Peak: 80.2 MB, Data Len: 10.0 M #^^ same list size, but new memory peak at roughly twice the usage Peak: 80.2 MB, Data Len:1.0 M Peak: 80.2 MB, Data Len:1.0 M Peak: 80.2 MB, Data Len: 10.0 M Peak: 80.2 MB, Data Len: 10.0 M Peak: 118.3 MB, Data Len: 20.0 M #^^ and again... (20+10)*c Peak: 118.3 MB, Data Len:1.0 M Peak: 118.3 MB, Data Len:1.0 M Peak: 118.3 MB, Data Len: 20.0 M Peak: 156.5 MB, Data Len: 20.0 M #^^ and again. (20+20)*c Peak: 156.5 MB, Data Len:1.0 M Peak: 156.5 MB, Data Len:1.0 M The crazy belt-and-suspenders-and-duct-tape approach `data = None`, `del data`, and `gc.collect()` does nothing. I'm pretty sure the generator itself is not doubling up on memory because otherwise a single large value it yields would increase the peak usage, and in the *same iteration* a large object appeared; it's only large consecutive objects. How can I save my memory? Cheers, Nick cc: StackOverflow http://stackoverflow.com/q/21787099/194586 -- https://mail.python.org/mailman/listinfo/python-list
Re: Generator using item[n-1] + item[n] memory
Ah, I think I was equating `yield` too closely with `return` in my head. Whereas `return` results in the destruction of the function's locals, `yield` I should have known keeps them around, a la C's `static` functions. Many thanks! -- https://mail.python.org/mailman/listinfo/python-list
Re: Generator using item[n-1] + item[n] memory
OK, now the trick; adding `data = None` inside the generator works, but in my actual code I wrap my generator inside of `enumerate()`, which seems to obviate the fix. Can I get it to play nice or am I forced to count manually. Is that a feature? On Fri, Feb 14, 2014 at 9:21 PM, Roy Smith r...@panix.com wrote: In article mailman.6952.1392433921.18130.python-l...@python.org, Nick Timkovich prometheus...@gmail.com wrote: Ah, I think I was equating `yield` too closely with `return` in my head. Whereas `return` results in the destruction of the function's locals, `yield` I should have known keeps them around, a la C's `static` functions. Many thanks! It's not quite like C's static. With C's static, the static variables are per-function. In Python, yield creates a context per invocation. Thus, I can do def f(): for i in range(1): yield i g1 = f() g2 = f() print g1.next() print g1.next() print g1.next() print g2.next() print g1.next() which prints 0, 1, 2, 0, 3. There's two contexts active at the same time, with a distinct instance of i in each one. -- https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list
Re: Async serial communication/threads sharing data
On Mar 21, 9:19 pm, Jean-Paul Calderone exar...@divmod.com wrote: On Sat, 21 Mar 2009 13:52:21 -0700 (PDT), Nick Timkovich prometheus...@gmail.com wrote: I've been working on a program that will talk to an embedded device over the serial port, using some basic binary communications with messages 4-10 bytes long or so. Most of the nuts and bolts problems I've been able to solve, and have learned a little about the threading library to avoid blocking all action while waiting for responses (which can take 50 ms to 10 s). Ultimately, this program will test the device on the COM port by sending it messages and collecting responses for 10k-100k cycles; a cycle being: 1. tell it to switch a relay, 2. get it's response from the event, 3. ask it for some measurements, 4. get measurements, 5. repeat. Later I would like to develop a GUI as well, but not a big issue now (another reason to use threads? not sure). Twisted includes serial port support and will let you integrate with a GUI toolkit. Since Twisted encourages you to write programs which deal with things asynchronously in a single thread, if you use it, your concerns about data exchange, locking, and timing should be addressed as a simple consequence of your overall program structure. Jean-Paul I've looked at Twisted a little bit because of some searches on serial port comm turning up advice for it. However, there seems to be no/ minimal documentation for the serial portions, like they are some old relic that nobody uses from this seemingly massive package. Do you have any examples or somewhere in particular you could point me? Thanks for the responses, Nick -- http://mail.python.org/mailman/listinfo/python-list
Async serial communication/threads sharing data
I've been working on a program that will talk to an embedded device over the serial port, using some basic binary communications with messages 4-10 bytes long or so. Most of the nuts and bolts problems I've been able to solve, and have learned a little about the threading library to avoid blocking all action while waiting for responses (which can take 50 ms to 10 s). Ultimately, this program will test the device on the COM port by sending it messages and collecting responses for 10k-100k cycles; a cycle being: 1. tell it to switch a relay, 2. get it's response from the event, 3. ask it for some measurements, 4. get measurements, 5. repeat. Later I would like to develop a GUI as well, but not a big issue now (another reason to use threads? not sure). The overall structure of what I should do is not very apparent to me on how to efficiently deal with the communications. Have the main loop handle the overall timing of how often to run the test cycle, then have a thread deal with all the communications, and within that another thread that just receives data? My main issue is with how to exchange data between different threads; can I just do something like have a global list of messages, appending, modifying, and removing as needed? Does the threading.Lock object just prevent every other thread from running, or is it bound somehow to a specific object (like my list)? -- http://mail.python.org/mailman/listinfo/python-list