Pygments 2.0.2 released
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 I'm happy to announce the release of Pygments 2.0.2. Pygments is a generic syntax highlighter written in Python. The 2.0.2 release contains a fix for a prominent bug that would duplicate tracebacks in the Python console lexer that's used, among others, for the display of doctest blocks in Sphinx. It is recommended to update. Report bugs and feature requests in the issue tracker: http://bitbucket.org/birkenfeld/pygments-main/issues. Download it from http://pypi.python.org/pypi/Pygments, or look at the demonstration at http://pygments.org/demo. Enjoy, Georg -BEGIN PGP SIGNATURE- Version: GnuPG v2 iEYEARECAAYFAlS9/q0ACgkQN9GcIYhpnLBM/QCdHwlKidM0pbxx9vowrdenAqBK YM0AniGfB/jFWdvqPlM4wmZRg166km9Z =oE6G -END PGP SIGNATURE- -- https://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations/
[issue1508475] transparent gzip compression in urllib
Martin Panter added the comment: The Lib/xmlrpc/client.py file appears to already support compression using “Content-Encoding: gzip”. Perhaps it could be leveraged for any work on this issue. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1508475 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23269] Tighten-up search loops in sets
Changes by Raymond Hettinger raymond.hettin...@gmail.com: -- resolution: - rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23269 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23281] Access violation - pyc file
eryksun added the comment: You attached a corrupt bytecode cache for stdlib bisect.py: f = open('test.pyc', 'rb') magic,tstamp = struct.unpack('ll', f.read(8)) magic27 = 62211 | (ord('\r') 16) | (ord('\n') 24) magic == magic27 True datetime.fromtimestamp(tstamp) datetime.datetime(2011, 3, 8, 2, 39, 36) code = marshal.load(f) dis.dis(code) 1 0 LOAD_CONST 0 ('Bisection algorithms.') 3 STORE_NAME 0 (__doc__) 3 6 LOAD_CONST 1 (0) 9 LOAD_CONST 8 (None) 12 LOAD_CONST 2 (code object insort_right at 0x7f71bf596db0, file C:\Python27\Lib\bisect.py, line 3) 15 MAKE_FUNCTION2 18 STORE_NAME 2 (insort_right) 22 21 LOAD_NAME65282 Traceback (most recent call last): File stdin, line 1, in module File /usr/lib/python2.7/dis.py, line 43, in dis disassemble(x) File /usr/lib/python2.7/dis.py, line 97, in disassemble print '(' + co.co_names[oparg] + ')', IndexError: tuple index out of range It's no surprise if this bad file crashed the interpreter. Just delete it. -- nosy: +eryksun ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23281 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18898] Apply the setobject optimizations to dictionaries
Changes by Raymond Hettinger raymond.hettin...@gmail.com: -- versions: +Python 3.5 -Python 3.4 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18898 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Re: Trees
On Mon, Jan 19, 2015 at 11:52 PM, Devin Jeanpierre jeanpierr...@gmail.com wrote: On Mon, Jan 19, 2015 at 3:08 PM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: Zachary Gilmartin wrote: Why aren't there trees in the python standard library? Possibly because they aren't needed? Under what circumstances would you use a tree instead of a list or a dict or combination of both? That's not a rhetorical question. I am genuinely curious, what task do you have that you think must be solved by a tree? In general, any time you want to maintain a sorted list or mapping, balanced search tree structures come in handy. Here's an example task: suppose you want to represent a calendar, where timeslots can be reserved for something. Calendar events are not allowed to intersect. Maybe because I'm not a computer scientist, I can't immediately see why this is a Tree problem and not a Database problem. Genuinely interested. -- https://mail.python.org/mailman/listinfo/python-list
[issue23275] Can assign [] = (), but not () = []
Kyle Buzsaki added the comment: It seems that assigning to [] is the odd one out in this case. Why is this even possible? [] = () [] = {} [] = set() list() = () File stdin, line 1 SyntaxError: can't assign to function call () = [] File stdin, line 1 SyntaxError: can't assign to () {} = [] File stdin, line 1 SyntaxError: can't assign to literal set() = [] File stdin, line 1 SyntaxError: can't assign to function call -- nosy: +Kyle.Buzsaki ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23275 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23255] SimpleHTTPRequestHandler refactor for more extensible usage.
Ent added the comment: Following is updated patch with * Refactored code with helper functions * Unit Tests * Documentation - Explanation + Examples SimpleHTTPRequestHandler's copyfile has been renamed to copy_file but not shutils'. -- Added file: http://bugs.python.org/file37786/helpers-unittests-docs.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23255 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23275] Can assign [] = (), but not () = []
Martin Panter added the comment: But () is the odd one out if you consider [a, b] = range(2) [] = range(0) (a, b) = range(2) () = range(0) File stdin, line 1 SyntaxError: can't assign to () -- nosy: +vadmium ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23275 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23276] hackcheck is broken in association with __setattr__
Alfred Krohmer added the comment: Can you elaborate what QtClass and QtMeta is in your case? My original example was reduced to a minimal case and seems to work with your suggestions. The complete example involving SQLalchemy is here: http://stackoverflow.com/questions/28032928/sqlalchemy-multiple-base-classes-not-working and does, however, not work. If I try to do # ... def __setattr__(cls, key, value): super(type(QMediaPlaylist), cls).__setattr__(cls, key, value) return The program segfaults when instantiating the Playlist class. However, this approach seems a little bit strange to me anyhow. The same happens when I try to do: # ... def __setattr__(cls, key, value): super(type(base), cls).__setattr__(cls, key, value) return I think that comes from PyQt specific attributes SQLalchemy is trying to set / replace. So, coming back to the original question, how can I actually set an attribute of my class Playlist from within its metaclass without involving the parent classes of the subclass (type(base) and type(QMediaPlaylist))? Because the __setattr__ from PyQt won't work (segfault) and the one from SQLalchemy does stupid stuff. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23276 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
pyzeliard - zeliard clone GPLv2
Hello, The old Sierra-On-Line game zeliard has been ported to python-pygame. The features for now are : fighting, cavern code, jumping, moving around and room exits. There is also some weapon store, bank and fortune teller work. You start in Bosque Town and can go to the Cavern of Malicia. I will try to stay as close to the real thing as I can. The code is at https://sourceforge.net/projects/pyzeliard/files/ The license is GPL version 2. Enjoy, Automn -- my blog : http://thediaryofelvishhealer.blogspot.com/ Time heals. -- https://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations/
[issue23276] hackcheck is broken in association with __setattr__
eryksun added the comment: def __setattr__(cls, key, value): super(type(QMediaPlaylist), cls).__setattr__(cls, key, value) return The program segfaults when instantiating the Playlist class. I'd expect a TypeError because of the extra cls argument. It's already a bound method. FYI, the above finds the next metaclass after type(QMediaPlaylist) in PlaylistMeta.__mro__. It happens that type(QMediaPlaylist) inherits __setattr__ from the next in line (sip.wrappertype), so by a stroke of luck it 'works' (not really since this skips the incompatible sqlalchemy __setattr__). Consider making a playlist class that *has* a SQL table, not one that *is* a SQL table, i.e. use composition instead of inheritance. That sidesteps the incompatible metaclasses. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23276 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1602] windows console doesn't print or input Unicode
Mark Hammond added the comment: File redirection has nothing to do with win-unicode-console Thank you, that comment is spot on - there are multiple issues being conflated here. This bug is purely about the tty/console behaviour. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1602 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23282] Slightly faster set lookup
New submission from Serhiy Storchaka: Currently set_lookkey() first tests entry-key == NULL, then entry-hash == hash and entry-key != dummy, and only after that entry-key == key. Proposed patch optimizes the order of comparisons. entry-key == key is tested first as for dicts. And no need to test entry-key != dummy after entry-hash == hash if entry-hash of dummy key is set to -1. Microbenchmark which demonstrates the best case (a lot of lookups of keys existing in the set). $ ./python -m timeit -s a = list(range(10**6)); s1 = set(a); s2 = set(a) -- s1 = s2 Unpatched: 10 loops, best of 3: 39.4 msec per loop Patched: 10 loops, best of 3: 35.3 msec per loop -- components: Interpreter Core files: set_faster_lookup.patch keywords: patch messages: 234367 nosy: pitrou, rhettinger, serhiy.storchaka priority: normal severity: normal stage: patch review status: open title: Slightly faster set lookup type: performance versions: Python 3.5 Added file: http://bugs.python.org/file37789/set_faster_lookup.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23282 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue2292] Missing *-unpacking generalizations
Neil Girdhar added the comment: Yup, that's it. So two problems down: It has yet to be updated to the most recent Python version It features a now redundant replacement for yield from which should be removed I'm working on: It also loses support for calling function with keyword arguments before positional arguments, which is an unnecessary backwards-incompatible change. I'm waiting on some feedback from python-ideas to make sure I know what should be allowed post PEP448. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue2292 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue2292] Missing *-unpacking generalizations
Berker Peksag added the comment: Python/ast.c:2433:5: error: ‘npositionals’ undeclared (first use in this function) Line 2425 should be int i, nargs, nkeywords, npositionals, ngens; -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue2292 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue2292] Missing *-unpacking generalizations
Changes by Fred L. Drake, Jr. fdr...@gmail.com: -- nosy: -fdrake ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue2292 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue2292] Missing *-unpacking generalizations
Neil Girdhar added the comment: Hi Chris. It might be hard to notice, but you're seeing the same build failure. Looking at the patch-to-patch differences, I didn't see anything out of the ordinary. My patch file includes more surrounding lines, dates, and is against a different repository, so it sees a lot of the new matrix multiplication operator stuff, etc. Is there a best practice for creating diff files? I just did hg diff starunpack3.diff. Anyway, here's a new patch with the yield *args code that has been supplanted by yield from removed. -- Added file: http://bugs.python.org/file37787/starunpack4.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue2292 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue2292] Missing *-unpacking generalizations
Changes by Neil Girdhar mistersh...@gmail.com: Added file: http://bugs.python.org/file37788/starunpack4.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue2292 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue2292] Missing *-unpacking generalizations
Changes by Neil Girdhar mistersh...@gmail.com: Removed file: http://bugs.python.org/file37787/starunpack4.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue2292 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue2292] Missing *-unpacking generalizations
Chris Angelico added the comment: *facepalm* Of course I am. I don't know how I missed that in there, but maybe I was focusing too much on the abort that followed it to actually read the exception text. Duh. But with the latest version of the patch, I'm seeing something that I'm fairly sure *is* a different failure: gcc -pthread -c -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes-Werror=declaration-after-statement -I. -IInclude -I./Include-DPy_BUILD_CORE -o Python/ast.o Python/ast.c Python/ast.c: In function ‘ast_for_call’: Python/ast.c:2433:5: error: ‘npositionals’ undeclared (first use in this function) Python/ast.c:2433:5: note: each undeclared identifier is reported only once for each function it appears in make: *** [Python/ast.o] Error 1 -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue2292 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Re: Trees
Terry Reedy tjre...@udel.edu: Others have answered as to why other special-purpose constrained-structure trees have not been added to the stdlib. Ordered O(log n) mappings are not special-purpose data structures. I'd say strings and floats are much more special-purpose than ordered mappings, and yet Python has direct support for those. As I said, I use ordered mappings to implement timers. GvR uses the heapq module for the purpose. The downside of heapq is that canceled timers often flood the heapq structure; in networking you can easily start a thousand timers a second but virtually no timer ever expires. Python's asyncio ignores the problem, but GvR mentioned a periodic garbage collection as a potentially effective solution. I tested the garbage collection trick and it did seem very effective. Marko -- https://mail.python.org/mailman/listinfo/python-list
[issue23275] Can assign [] = (), but not () = []
eryksun added the comment: In ast.c, set_context checks for assignment to an empty tuple, but not an empty list. case List_kind: e-v.List.ctx = ctx; s = e-v.List.elts; break; case Tuple_kind: if (asdl_seq_LEN(e-v.Tuple.elts)) { e-v.Tuple.ctx = ctx; s = e-v.Tuple.elts; } else { expr_name = (); } break; https://hg.python.org/cpython/file/ab2c023a9432/Python/ast.c#l912 -- nosy: +eryksun ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23275 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Chennai Python User Group - January Meetup
Hi Everyone, The Chennai Python User Group (Chennaipy) is meeting on 31st Jan, at IMSc, Chennai. For more details about the event, visit our meetup event page http://www.meetup.com/Chennaipy/events/219692997/ If you are interested, RSVP on our meetup page. Website: http://chennaipy.org Mailing List: https://mail.python.org/mailman/listinfo/chennaipy Regards, Vijay -- https://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations/
[issue23281] Access violation - pyc file
Brett Cannon added the comment: If it was created by a fuzzer then this isn't a bug as we do no validation of bytecode formatting as we assume it was generated by Python and not an external, malicious source. -- nosy: +brett.cannon resolution: - not a bug status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23281 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Re: Trees
On Tuesday, January 20, 2015 at 7:03:56 PM UTC+5:30, Rustom Mody wrote: On Tuesday, January 20, 2015 at 11:38:27 AM UTC+5:30, Terry Reedy wrote: On 1/19/2015 5:06 PM, Zachary Gilmartin wrote: Why aren't there trees in the python standard library? Sequences nested withing sequences can be regarded as trees, and Python has these. I regard Lisp as a tree processing languages, as it must be to manipulate, for example, code with nested structures. Yeah python has trees alright. It may be best to read my example above in this order: 1. See the picture at http://www-math.ucdenver.edu/~wcherowi/courses/m4408/gtln8.html 2. Take the python representation of that t [I, 6, [I, 2, [L, 1], [I, 4, [L, 3], [L, 5]]], [I, 8, [L, 7], [L, 9]]] Indent that a bit: [I, 6, [I, 2, [L, 1], [I, 4, [L, 3], [L, 5]]], [I, 8, [L, 7], [L, 9]]] Now compare with the picture above Only catch is you must see it 'lying down' Shouldn't be too hard given that we've all got used to seeing :-) as a smiley :-) -- https://mail.python.org/mailman/listinfo/python-list
[issue23281] Access violation - pyc file
Paweł Zduniak added the comment: This file is created by fuzzer -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23281 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Re: Trees
On 20/01/2015 05:19, Marko Rauhamaa wrote: Mark Lawrence breamore...@yahoo.co.uk: On 19/01/2015 22:06, Zachary Gilmartin wrote: Why aren't there trees in the python standard library? Probably because you'd never get agreement as to which specific tree and which specific implementation was the most suitable for inclusion. Most programming languages provide one standard sorted mapping implementation. I'd have thought it would be the standard library and not the language that provided a sorted mapping. Are you also saying that this has to be implemented as a tree, such that this has to be provided by cPython, Jython, IronPython, Pypy and so on and so forth? -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence -- https://mail.python.org/mailman/listinfo/python-list
Re: Trees
On Tuesday, January 20, 2015 at 7:46:02 PM UTC+5:30, Marko Rauhamaa wrote: Rustom Mody : Yeah python has trees alright. Does Python balance them for you? No Does python support a menagerie of lists like C - singly linked, doubly linked, with header, without header etc? Or access to machine registers like assembly? And are these differences from C/Assembly in favor or against python? -- https://mail.python.org/mailman/listinfo/python-list
Re: Trees
On Tuesday, January 20, 2015 at 11:38:27 AM UTC+5:30, Terry Reedy wrote: On 1/19/2015 5:06 PM, Zachary Gilmartin wrote: Why aren't there trees in the python standard library? Sequences nested withing sequences can be regarded as trees, and Python has these. I regard Lisp as a tree processing languages, as it must be to manipulate, for example, code with nested structures. Yeah python has trees alright. Heres' some simple tree-code from enum import Enum class TreeTag(Enum): I = 0 # An internal node L = 1 # A leaf node def __repr__(self): return self.name I = TreeTag.I L = TreeTag.L def dfs(t): if t[0] == L: return [t[1]] else: return [t[1]] + dfs(t[2]) + dfs(t[3]) # Converting to generators is trivial = # Example tree # From http://www-math.ucdenver.edu/~wcherowi/courses/m4408/gtln8.html t1 = [L, 1] t4 = [I, 4, [L, 3],[L,5]] t2 = [I, 2, t1, t4] t8 = [I, 8, [L, 7], [L, 9]] # Top level tree t = [I, 6, t2, t8] == An REPL session t [I, 6, [I, 2, [L, 1], [I, 4, [L, 3], [L, 5]]], [I, 8, [L, 7], [L, 9]]] dfs(t) [6, 2, 1, 4, 3, 5, 8, 7, 9] t8 [I, 8, [L, 7], [L, 9]] dfs(t8) [8, 7, 9] -- https://mail.python.org/mailman/listinfo/python-list
[issue23281] Access violation - pyc file
Eric V. Smith added the comment: Was this file generated by CPython from a .py file? If so, can you share the .py file? If not, how was this file generated? As eryksun says, it appears to not be a valid .pyc file. -- nosy: +eric.smith ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23281 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Re: Random ALL CAPS posts on this group
Rick Johnson rantingrickjohn...@gmail.com writes: No one here would justify a public business refusing to serve or employ a person based on race, religion, sex, or otherwise. Depends on what you mean by or otherwise. So why would you so easily discriminate against speech? People discriminate amongst prospective employees on the basis of what the say all the time. It's the principle method by which you assess candidates. Freedom of expression is not about requiring others to publish your words. It would be completely impractical - where would it end? Your own slot on prime time TV to rant as you choose? -- https://mail.python.org/mailman/listinfo/python-list
Re: Trees
On Mon, Jan 19, 2015 at 6:46 PM, Mark Lawrence breamore...@yahoo.co.uk wrote: I don't know if you've seen this http://kmike.ru/python-data-structures/ but maybe of interest. I haven't read but also possibly of interest: Data Structures and Algorithms in Python by Michael T. Goodrich, Roberto Tamassia, Michael H. Goldwasser (Wiley, 2013) [1] Python Algorithms: Mastering Basic Algorithms in the Python Language, 2nd Edition by Magnus Lie Hetland (Apress, 2014) [2] [1] http://www.wiley.com/WileyCDA/WileyTitle/productCd-EHEP002510.html [2] http://www.apress.com/9781484200568 -- https://mail.python.org/mailman/listinfo/python-list
Re: Trees
Rustom Mody rustompm...@gmail.com: Yeah python has trees alright. Does Python balance them for you? Marko -- https://mail.python.org/mailman/listinfo/python-list
[issue23281] Access violation - pyc file
STINNER Victor added the comment: we assume it was generated by Python and not an external, malicious source. Said differently: you must not trust .py or .pyc downloaded from untrusted sources. Executing arbitary .py or .pyc file allows to execute arbitrary Python code. Instead of writing complex code to inject machine code in the Python evaluation loop (Python/ceval.c), just execute import os; os.system('echo pwn!') which runs an arbitrary shell command. Compile it to .pyc if you want to exploit the PYC path. -- nosy: +haypo ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23281 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue2292] Missing *-unpacking generalizations
Joshua Landau added the comment: The problem seems to be that with the removal of -else if (TYPE(ch) == STAR) { -vararg = ast_for_expr(c, CHILD(n, i+1)); -if (!vararg) -return NULL; -i++; -} -else if (TYPE(ch) == DOUBLESTAR) { -kwarg = ast_for_expr(c, CHILD(n, i+1)); -if (!kwarg) -return NULL; -i++; -} the code will ignore any subnodes that aren't of type argument. However, the grammar still says arglist: (argument ',')* (argument [','] | '*' test [',' '**' test] | '**' test) so this is incorrect. Here's an example of what you might get inner( a,argument comma *bcd, star test comma e,argument comma f=6,argument comma **{g: 7}, doublestar test comma h=8,argument comma **{i:9} doublestar test ) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue2292 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue2292] Missing *-unpacking generalizations
Neil Girdhar added the comment: Yes, thank you! That explained it. I am almost done fixing this patch. Here's my progress so far if you want to try it out. Just one test left to fix. -- Added file: http://bugs.python.org/file37790/starunpack5.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue2292 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue3566] httplib persistent connections violate MUST in RFC2616 sec 8.1.4.
Demian Brecht added the comment: TL;DR: Because HTTP is an application-level protocol, it's nearly impossible to gauge how a server will behave given a set of conditions. Because of that, any time that assumptions can be avoided, they should be. @R. David Murray: That is, if the connection has been closed, I think an operation attempted on the connection should raise an exception that makes it clear that the connection is closed (in the case of some stdlib modules, that may be a socket level exception for the operation on the closed socket). In the typical case, this is exactly what happens. This issue is around a race condition that can occur between the client issuing a request prior to terminating the connection with the server, but the server terminating it prior to processing the request. In these cases, the client is left in a state where as far as it's concerned, it's in a valid state waiting for a response which the server will not issue as it has closed the socket on its side. In this case, the client reading an empty string from the receive buffer implies a closed socket. Unfortunately, it's not entirely uncommon when using persistent connections, as Martin's examples demonstrate. I think the remote server writing a blank line to the socket is a very different thing from the remote server closing the connection without writing anything, so I may be misunderstanding something here. +1. What Martin is arguing here (Martin, please correct me if I'm wrong) is that a decently behaved server should not, at /any/ time write a blank line to (or effectively no-op) the socket, other than in the case where the socket connection has been closed. While I agree in the typical case, a blend of Postel and Murphy's laws leads me to believe it would be better to expect, accept and handle the unexpected. @Martin: Here's a concrete example of the unexpected behaviour. It's not specific to persistent connections and would be caught by the proposed first request solution, but ultimately, similar behaviour may be seen at any time from other servers/sources: http://stackoverflow.com/questions/22813645/options-http-methods-gives-an-empty-response-on-heroku. Googling for http empty response and similar search strings should also provide a number of examples where unexpected behaviour is encountered and in which case raising an explicit ConnectionClosed error would add to the confusion. Other examples are really hypotheticals and I don't think it's worth digging into them too deeply here. Unexpected behaviour (regardless of whether it's on the first or Nth request) should be captured well enough by now. Eventually the server _would_ probably drop the connection (so ConnectionClosed would not be misleading) Sure, but you're raising an exception based on future /expected/ behaviour. That's my issue with the proposed solution in general. ConnectionClosed assumes specific behaviour, where literally /anything/ can happen server side. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue3566 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Re: Trees
On Tue, Jan 20, 2015 at 6:33 AM, Rustom Mody rustompm...@gmail.com wrote: from enum import Enum class TreeTag(Enum): I = 0 # An internal node L = 1 # A leaf node def __repr__(self): return self.name I = TreeTag.I L = TreeTag.L Explicitly tagging nodes as internal or leaves is kind of ugly and also prone to getting out of sync with the reality, which is that a node is a leaf if it doesn't have any other nodes hanging off of it. def dfs(t): if t[0] == L: return [t[1]] else: return [t[1]] + dfs(t[2]) + dfs(t[3]) Over the entire tree, this will do O(n) list additions which implies O(n) list *copies*, which is rather inefficient. This would probably be better implemented as a recursive generator. def dfs(t): yield t[0] yield from chain.from_iterable(map(dfs, islice(t, 1, None))) # Converting to generators is trivial = :-) -- https://mail.python.org/mailman/listinfo/python-list
[issue2292] Missing *-unpacking generalizations
Neil Girdhar added the comment: All tests pass for me! Would anyone be kind enough to do a code review? -- Added file: http://bugs.python.org/file37791/starunpack6.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue2292 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Re: Trees
Marko Rauhamaa ma...@pacujo.net writes: As I said, I use ordered mappings to implement timers... The downside of heapq is that canceled timers often flood the heapq structure..., GvR mentioned a periodic garbage collection as a potentially effective solution. You could look up the timer wheel approach used by the Linux kernel and by Erlang. It's less general than an ordered map, but probably faster in practice. https://lkml.org/lkml/2005/10/19/46 Has some info. I think the kernel uses a different method now though. Fwiw, I believe that the Haskell i/o manager uses an ordered map, and it gets monstrous performance: http://haskell.cs.yale.edu/wp-content/uploads/2013/08/hask035-voellmy.pdf Some comments: http://ezyang.tumblr.com/post/62152700458/haskell-mio-a-high-performance-multicore-io -- https://mail.python.org/mailman/listinfo/python-list
Re: Trees
On Tuesday, January 20, 2015 at 10:51:13 PM UTC+5:30, Ian wrote: On Tue, Jan 20, 2015 at 6:33 AM, Rustom Mody wrote: from enum import Enum class TreeTag(Enum): I = 0 # An internal node L = 1 # A leaf node def __repr__(self): return self.name I = TreeTag.I L = TreeTag.L Explicitly tagging nodes as internal or leaves is kind of ugly and also prone to getting out of sync with the reality, which is that a node is a leaf if it doesn't have any other nodes hanging off of it. Yeah... Just demoing a technique for more variegated trees eg an AST for some toy DSL or some such. Imagine you have 10 types of nodes and one defaults to tagless def dfs(t): if t[0] == L: return [t[1]] else: return [t[1]] + dfs(t[2]) + dfs(t[3]) Over the entire tree, this will do O(n) list additions which implies O(n) list *copies*, which is rather inefficient. This would probably be better implemented as a recursive generator. Yeah def dfs(t): yield t[0] yield from chain.from_iterable(map(dfs, islice(t, 1, None))) # Converting to generators is trivial = :-) Less trivial than I thought... Why does this not work? def dfsg(t): if t[0] == L: yield t[1] else: yield from dfsg(t[2]) yield from dfsg(t[3]) -- https://mail.python.org/mailman/listinfo/python-list
pickle and then object changes
Say an object like this exists: class test: a = b = You pickle it. You change the object definition to have a new field: class test a = b = c = You read the pickled object. Will it load but ignore the new field? That is what I want. -- https://mail.python.org/mailman/listinfo/python-list
Re: Trees
On Tuesday, January 20, 2015 at 11:46:11 PM UTC+5:30, Rustom Mody wrote: On Tuesday, January 20, 2015 at 10:51:13 PM UTC+5:30, Ian wrote: On Tue, Jan 20, 2015 at 6:33 AM, Rustom Mody wrote: # Converting to generators is trivial = :-) Less trivial than I thought... Why does this not work? def dfsg(t): if t[0] == L: yield t[1] else: yield from dfsg(t[2]) yield from dfsg(t[3]) Ok got it Forgot the «yield t[1]» before the two yield-from's -- https://mail.python.org/mailman/listinfo/python-list
Re: pickle and then object changes
James Smith wrote: Say an object like this exists: class test: a = b = You pickle it. You change the object definition to have a new field: class test a = b = c = You read the pickled object. Will it load but ignore the new field? That is what I want. Classes are pickled by name. You are free to replace them with whatever you want: class Test: ... a = 1 ... b = 2 ... import pickle p = pickle.dumps(Test) class Test: ... a = 10 ... b = 20 ... c = 30 ... P = pickle.loads(p) P.c 30 P.a 10 P is Test True If you introduce a new *instance* attribute that will not magically appear on unpickling: class T: ... def __init__(self, a, b): ... self.a = a ... self.b = b ... def __str__(self): return T(a={0.a}, b={0.b}).format(self) ... t = T(1, 2) print(t) T(a=1, b=2) p = pickle.dumps(t) class T: ... def __init__(self, a, b, c): ... self.a = a ... self.b = b ... self.c = c ... def __str__(self): return T(a={0.a}, b={0.b}, c={0.c}).format(self) ... print(T(10, 20, 30)) T(a=10, b=20, c=30) v = pickle.loads(p) No problem so far as the initializer is not called so that the missing c is not a problem. But then: print(v) Traceback (most recent call last): File stdin, line 1, in module File stdin, line 6, in __str__ AttributeError: 'T' object has no attribute 'c' One easy fix is to use a class attribute as the fallback: T.c = class attribute print(v) T(a=1, b=2, c=class attribute) But remember not to try this with mutable attributes. When `c` is a list v.c.append(42) will affect all instances with a missing `c` instance attribute. -- https://mail.python.org/mailman/listinfo/python-list
[issue23266] Faster implementation to collapse non-consecutive ip-addresses
Markus added the comment: My initial patch was wrong wrt. _find_address_range. It did not loop over equal addresses. Thats why performance with many equal addresses was degraded when dropping the set(). Here is a patch to fix _find_address_range, drop the set, and improve performance again. python3 -m timeit -s import bipaddress; ips = [bipaddress.ip_address('2001:db8::1000') for i in range(1000)] -- bipaddress.collapse_addresses(ips) 1000 loops, best of 3: 1.76 msec per loop python3 -m timeit -s import aipaddress; ips = [aipaddress.ip_address('2001:db8::1000') for i in range(1000)] -- aipaddress.collapse_addresses(ips) 1000 loops, best of 3: 1.32 msec per loop -- Added file: http://bugs.python.org/file37794/ipaddress_faster_collapse4.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23266 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Re: Trees
Marko Rauhamaa ma...@pacujo.net writes: So in my Python software (both at work and at home) needs, I use a Python AVL tree implementation of my own. My use case is timers. (GvR uses heapq for the purpose.) Have you benchmarked your version against heapq or even the builtin sorting functions? -- https://mail.python.org/mailman/listinfo/python-list
[issue2292] Missing *-unpacking generalizations
Changes by Neil Girdhar mistersh...@gmail.com: Added file: http://bugs.python.org/file37792/starunpack6.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue2292 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
RE: Random ALL CAPS posts on this group
-Original Message- From: Python-list [mailto:python-list- bounces+crk=godblessthe...@python.org] On Behalf Of Rick Johnson Sent: Monday, January 19, 2015 8:06 PM To: python-list@python.org Subject: Re: Random ALL CAPS posts on this group On Monday, January 19, 2015 at 8:16:01 PM UTC-6, Ben Finney wrote: Freedom of expression entails an obligation on the state to not quash anyone's expression. It does not affect anyone who is not the state; it imposes no obligation on the PSF. [...] So a forum such as this can block obnoxious spam, and that choice does not impact anyone's freedom of expression. Ben, i know we have not agreed much in the past, and you may be thinking that i intend to pick a fight with you here (and i don't), however i implore you to give more thought to the vital importance of free expression. I believe that free speech is so important, so vital to the existence of free societies, that it's practice *MUST* extend far beyond the boundaries of the state's rule, and be fostered by *ANY* group who is in the public domain. No one here would justify a public business refusing to serve or employ a person based on race, religion, sex, or otherwise. So why would you so easily discriminate against speech? I agree that these spam posts are annoying, but that is not enough of an excuse to start limiting people's speech in a *PUBLIC* forum. If python-list were a private group for members only, then by all means make up whatever rules you want to. But when shared publicly, we have a duty to support freedom for *ALL*. We must suffer the annoyances if we want to enjoy freedom for all. -- https://mail.python.org/mailman/listinfo/python-list This is not a public forum; it ia quasi-public forum. It has a structure and understanding of what the topics are. Freedom of speech does not include anytime and anyplace. This is a captive audience and we can't choose what some fool is going to bore us with. Yes we can hit the delete key in one form or another. As much as I don't want to hear our Dear Leader tonight, I will choose to listen. (and then ridicule:)) But I don't want some psycho Islam Terrorist to stand up and commandeer the TSOTU speech just because he believes that he has the right to drivel on and on. We all agree that that is not the time, place, or topic for the speech. In civilized society, being a captive audience is not really associated with free speech. In civilized society we have a time and a place for a topic, and those that want to hear the pontificator are free to listen. You don't have the right to come in to my house and drivel: it is not the right time or place. Clayton -- https://mail.python.org/mailman/listinfo/python-list
Student looking for a Scitki-Learn Numpy Tutor with a strong background in data science?
In a Masters for Data Science and need the help using Python/R mainly. Please forward background(education, work) teaching experence in stats, linear algebra, programming (Scikit, Panda, Numpy), timezone, and rates. -- https://mail.python.org/mailman/listinfo/python-list
[issue3566] httplib persistent connections violate MUST in RFC2616 sec 8.1.4.
Demian Brecht added the comment: Now I think I'd like to take my foot out of my mouth. Previous quick experiments that I had done were at the socket level, circumventing some of the logic in the HTTPResponse, mainly the calls to readline() rather than simple socket.recv(N). I've confirmed that the /only/ way that the HTTPConnection object can possibly get a 0-length read is, in fact, if the remote host has closed the connection. In light of that, I have no objection at all to the suggested addition of ConnectionClosed exception and my apologies for the added confusion and dragging this issue on much longer than it should have been. I've also attached my proof of concept code for posterity. -- Added file: http://bugs.python.org/file37793/zero_response_poc.py ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue3566 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Re: Trees
Steven D'Aprano steve+comp.lang.pyt...@pearwood.info writes: Possibly because they aren't needed? Under what circumstances would you use a tree instead of a list or a dict or combination of both? I've sometimes wanted a functional tree in the sense of functional programming. That means the tree structure is immutable and you insert or delete nodes in O(log n) operations, by creating new trees that share almost all their data with the old tree. Once you release the old root, garbage collection frees any nodes that were in the old tree but not the new one. Use case inspired by Haskell's Happstack-store (formerly called MACID): you want a Prevayler-style in-memory key-value database. First idea: all read queries are served by pure in-memory lookups in a Python dict. Write queries update the dict and also append the command to a serial log on disk (one disk write, no seeks). If the system crashes, restart it empty, and play back the log from the beginning to restore the in-memory data. Problem with first idea: the database might be a few thousand entries but take millions of updates, if entries are modified frequently. You don't want to reload the million updates from the beginning. Next idea: dump a snapshot of the dictionary now and then, and then just reload updates starting from the last snapshot. Trouble here is that the dictionary is big enough that writing out the snapshot takes time, and you don't want to lock the whole dict against more updates while the snapshot is writing. If you do this the Java way, welcome to concurrency hell as you make finer and finer grained locks and deal with resulting deadlocks, race conditions, etc. And the dictionary still has to be synchronized to avoid reads simultaneous with updates. MACID solution: use a functional red-black tree instead of a dict. To add or update an entry, make a new tree that replaces the old tree by updating a single pointer. That allows unlimited read concurrency (reading means getting the current tree pointer and navigating the tree that you get: since that tree is immutable you can keep using it while other threads make new trees). Updates are managed by a single thread that can take its time making the new tree and writing the log, and then atomically updating the in-memory root pointer that's shared with other threads. Finally, to take a snapshot, you can just get the current root and write out its contents: since it's immutable you can do that concurrently with anything else (including updates) that might be happening. You just have a small interaction with the update thread to remember where in the log to start reading from in case of a crash and reload. Finding out about this was one of the wow moments that made me realize I had to learn Haskell. -- https://mail.python.org/mailman/listinfo/python-list
[issue23280] Convert binascii.{un}hexlify to Argument Clinic (fix docstrings)
Roundup Robot added the comment: New changeset 1cb2b46c5109 by Zachary Ware in branch '3.4': Issue #23280: Fix docstrings for binascii.(un)hexlify https://hg.python.org/cpython/rev/1cb2b46c5109 New changeset 754c630c98a3 by Zachary Ware in branch 'default': Merge with 3.4 (closes #23280) https://hg.python.org/cpython/rev/754c630c98a3 -- nosy: +python-dev resolution: - fixed stage: commit review - resolved status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23280 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23280] Convert binascii.{un}hexlify to Argument Clinic (fix docstrings)
Zachary Ware added the comment: Thanks for the (very quick!) review, Serhiy. -- assignee: - zach.ware ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23280 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Re: Trees
Exactly. There are over 23,000 different kinds of trees. There's no way you could get all of them to fit in a library, especially a standard one. Instead, we prefer to provide people with the tools they need to grow their own trees. http://caseytrees.org/programs/planting/ctp/ http://www.ncsu.edu/project/treesofstrength/treefact.htm http://en.wikipedia.org/wiki/Tree On 1/19/2015 3:01 PM, Mark Lawrence wrote: On 19/01/2015 22:06, Zachary Gilmartin wrote: Why aren't there trees in the python standard library? Probably because you'd never get agreement as to which specific tree and which specific implementation was the most suitable for inclusion. -- https://mail.python.org/mailman/listinfo/python-list
Re: Trees
There are similarly many kinds of hash tables. For a given use case (e.g. a sorted dict, or a list with efficient removal, etc.), there's a few data structures that make sense, and a library (even the standard library) doesn't have to expose which one was picked as long as the performance is good. -- Devin On Tue, Jan 20, 2015 at 12:15 PM, Ken Seehart k...@seehart.com wrote: Exactly. There are over 23,000 different kinds of trees. There's no way you could get all of them to fit in a library, especially a standard one. Instead, we prefer to provide people with the tools they need to grow their own trees. http://caseytrees.org/programs/planting/ctp/ http://www.ncsu.edu/project/treesofstrength/treefact.htm http://en.wikipedia.org/wiki/Tree On 1/19/2015 3:01 PM, Mark Lawrence wrote: On 19/01/2015 22:06, Zachary Gilmartin wrote: Why aren't there trees in the python standard library? Probably because you'd never get agreement as to which specific tree and which specific implementation was the most suitable for inclusion. -- https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list
[issue23266] Faster implementation to collapse non-consecutive ip-addresses
Serhiy Storchaka added the comment: Only one duplicated address is degenerated case. When there is a lot of duplicated addresses in range the patch causes regression. $ ./python -m timeit -s import ipaddress; ips = [ipaddress.ip_address('2001:db8::%x' % (i%100)) for i in range(10)] -- ipaddress.collapse_addresses(ips) Unpatched: 10 loops, best of 3: 369 msec per loop Patched: 10 loops, best of 3: 1.04 sec per loop -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23266 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Re: Trees
On Wed, Jan 21, 2015 at 7:15 AM, Ken Seehart k...@seehart.com wrote: Exactly. There are over 23,000 different kinds of trees. There's no way you could get all of them to fit in a library, especially a standard one. Instead, we prefer to provide people with the tools they need to grow their own trees. I'm not sure whether you're talking about algorithmic or arboreal trees here... I'm fairly sure the State Library of Victoria contains 23,000 trees, albeit in a slightly modified form. But the State Library is not a standard one. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: How to run a python script with functions
On Tuesday, 20 January 2015 17:11:58 UTC-4, faiz@gmail.com wrote: Hi I have a file with a python scripts that has many functions in it. To run the script I did the following: 1. $ python (to initiate python, using the python command) 2. import file_name (without .py) 3. file_name.function_name(argument) (to run the function_name with argument (argument) My question is: Is there any other way that I can just use the function name (function_name) without having to use the file_name. part? That is, use only: function_name(argument) from file_name import function1, function2 ~faizlo -- https://mail.python.org/mailman/listinfo/python-list
[issue2292] Missing *-unpacking generalizations
Joshua Landau added the comment: This was a rather minor fix; I basically moved from STORE_SUBSCR to STORE_MAP and fixed a BUILD_MAP opcode. -- Added file: http://bugs.python.org/file37795/starunpack7.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue2292 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23284] curses, readline, tinfo, and also --prefix, dbm, CPPFLAGS
Changes by Poor Yorick pooryor...@users.sourceforge.net: -- keywords: +patch Added file: http://bugs.python.org/file37796/34d54cc5ecfd.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23284 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue2292] Missing *-unpacking generalizations
Joshua Landau added the comment: Aye, I'd done so (see starunpack7.diff). It was the fuss to reapply it ontop of your newer diff and making sure I'd read at least *some* of the devguide before barging on. Anyhow, here's another small fix to deal with the [*[0] for i in [0]] problem. I'm not nearly confident I can touch the grammar, though, so the other problems are out of my reach. -- Added file: http://bugs.python.org/file37798/starunpack8.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue2292 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue2292] Missing *-unpacking generalizations
Neil Girdhar added the comment: I think there will still be a problem ceval with the way the dicts are combined unfortunately, but that should be easy to fix. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue2292 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Re: Random ALL CAPS posts on this group
On Mon, 19 Jan 2015 16:15:58 -0800, Luke Tomaneng wrote: Has anyone noticed these? There have been about three of them recently and they don't seem to have anything to do with Python at all. Does anyone know if there is a good reason they are here? Abusive spam from idiots. I have a regex that simply ignores any posting with no lower case in the subject. -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list
[issue2292] Missing *-unpacking generalizations
Joshua Landau added the comment: I'm getting f(x=5, **{'x': 1}, **{'x': 3}, y=2) Traceback (most recent call last): File stdin, line 1, in module TypeError: f() got multiple values for keyword argument 'x' Which, as I understand, is the correct result. I'm using starunpack8.diff right now. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue2292 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue2292] Missing *-unpacking generalizations
Joshua Landau added the comment: The problem with using STORE_MAP is you create a new dict for each keyword argument in that situation. You don't; if you look at the disassembly for producing a built-in dict (dis.dis('{1:2, 2:3, 3:4}')) you'll see they use STORE_MAP too. STORE_MAP seems to just be the map equivalent of LIST_APPEND. I've done simple timings that show my version being faster... Unfortunately, it points out there is definitely a memory leak. This reproduces: def f(a): pass while True: f(**{}, a=1) This goes for both patches 8 and 9. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue2292 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue2292] Missing *-unpacking generalizations
Joshua Landau added the comment: I think I've got it working; I'm just working out how to make a patch and adding a test or two. I think I'll also need to sign the contributor agreement. While I'm at it, here are a few other deviations from the PEP: - {*()} and {**{}} aren't supported - [*[0] for i in [0]] gives a SystemError - return *(1, 2, 3), fails whilst *(1, 2, 3), succeeds -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue2292 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23287] ctypes.util.find_library needlessly call crle on Solaris
New submission from John Beck: On Solaris, in Lib/ctypes/util.py, we have code that looks for /usr/bin/crle and calls it to parse its output to try to determine the Default Library Path. This code broke recently (Solaris 12 build 65), as it expects to find a line starting with Default Library Path (ELF): but the (ELF) part of that line was removed because it was no longer needed. So we need a change here regardless. But it turns out that calling crle is not needed at all because the default library path is a constant on Solaris: /lib/64:/usr/lib/64 in 64-bit mode and /lib:/usr/lib in 32-bit mode. Thus I offer the attached patch for both 2.7 and 3.4. -- components: ctypes files: crle-fix.patch keywords: patch messages: 234417 nosy: jbeck priority: normal severity: normal status: open title: ctypes.util.find_library needlessly call crle on Solaris type: resource usage versions: Python 2.7, Python 3.4 Added file: http://bugs.python.org/file37800/crle-fix.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23287 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue2292] Missing *-unpacking generalizations
Neil Girdhar added the comment: Ah, nice! I didn't realize what STORE_MAP did. I thought it created a map each time. We'll just do it your way. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue2292 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Re: How to run a python script with functions
On Tuesday, January 20, 2015 at 3:22:55 PM UTC-6, André Roberge wrote: On Tuesday, 20 January 2015 17:11:58 UTC-4, faiz@gmail.com wrote: Hi I have a file with a python scripts that has many functions in it. To run the script I did the following: 1. $ python (to initiate python, using the python command) 2. import file_name (without .py) 3. file_name.function_name(argument) (to run the function_name with argument (argument) My question is: Is there any other way that I can just use the function name (function_name) without having to use the file_name. part? That is, use only: function_name(argument) from file_name import function1, function2 ~faizlo Thank you André -- https://mail.python.org/mailman/listinfo/python-list
[issue23208] asyncio: add BaseEventLoop._current_handle (only used in debug mode)
Changes by STINNER Victor victor.stin...@gmail.com: -- title: asyncio: add BaseEventLoop._current_handle - asyncio: add BaseEventLoop._current_handle (only used in debug mode) ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23208 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23285] PEP 475 - EINTR hanndling
Changes by Charles-François Natali cf.nat...@gmail.com: -- components: Library (Lib) hgrepos: 293 nosy: haypo, neologix, pitrou priority: normal severity: normal status: open title: PEP 475 - EINTR hanndling type: enhancement ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23285 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue2292] Missing *-unpacking generalizations
Neil Girdhar added the comment: Post it? It's just hg diff a.diff -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue2292 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Re: Trees
On 20/01/15 01:49, Dan Stromberg wrote: I think probably the most common need for a tree is implementing a cache, That is probably true, at least if you're a squirrel. -- https://mail.python.org/mailman/listinfo/python-list
[issue2292] Missing *-unpacking generalizations
Neil Girdhar added the comment: If there is a speed issue, the real answer I think is to add an opcode as suggested in the source code that coalesces keyword arguments into dicts rather than the weird dance as the previous authors described it, or turning each argument into an individual dict and merging them at the end as you're doing… -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue2292 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23285] PEP 475 - EINTR hanndling
Changes by Charles-François Natali cf.nat...@gmail.com: -- keywords: +patch Added file: http://bugs.python.org/file37797/ff1274594739.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23285 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue2292] Missing *-unpacking generalizations
Neil Girdhar added the comment: Thanks! I've incorporated your changes to deal with the [*[0] for i in [0]] problem, although I don't understand them yet. The problem with using STORE_MAP is you create a new dict for each keyword argument in that situation. I optimized that away. Good catch on the BUILD_MAP opcode problem. I could not figure out why that wasn't working! I added some tests. Did you say you had some tests? One of the tests that both of our code is failing on still is: def f(x, y): ... print(x, y) ... f(x=5, **{'x': 1}, **{'x': 3}, y=2) It's just a problem in ceval that I'll work on now. -- Added file: http://bugs.python.org/file37799/starunpack9.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue2292 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue2292] Missing *-unpacking generalizations
Guido van Rossum added the comment: SGTM On Tue, Jan 20, 2015 at 4:08 PM, Neil Girdhar rep...@bugs.python.org wrote: Neil Girdhar added the comment: That makes sense. If you wanted to override, you could always write: f(**{**a, **b, 'x': 5}) rather than f(**a, **b, x=5) Should I go ahead and fix it so that overriding is always wrong? E.g., f(**{'x': 3}, **{'x': 4}) which currently works? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue2292 ___ -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue2292 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
How to run a python script with functions
Hi I have a file with a python scripts that has many functions in it. To run the script I did the following: 1. $ python (to initiate python, using the python command) 2. import file_name (without .py) 3. file_name.function_name(argument) (to run the function_name with argument (argument) My question is: Is there any other way that I can just use the function name (function_name) without having to use the file_name. part? That is, use only: function_name(argument) ~faizlo -- https://mail.python.org/mailman/listinfo/python-list
[issue23285] PEP 475 - EINTR hanndling
New submission from Charles-François Natali: The test runs fine on Linux, but hangs in test_send() on OS-X and *BSD. I don't know what's wrong, so if someone with access to one of these OS could have a look, it would be great. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23285 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23285] PEP 475 - EINTR handling
Antoine Pitrou added the comment: Perhaps Ned can help on the OS X side of things. -- nosy: +ned.deily ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23285 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue2292] Missing *-unpacking generalizations
Guido van Rossum added the comment: Let's tread careful here. In regular dicts, for better or for worse, {'x': 1, 'x': 2} is defined and returns {'x': 2}. But in keyword arg processing, duplicates are always rejected. This may be an area where we need to adjust the PEP to match that expectation. On Tue, Jan 20, 2015 at 3:51 PM, Neil Girdhar rep...@bugs.python.org wrote: Neil Girdhar added the comment: Why is that correct? The PEP mentions overriding. Right now each dict overrides values from the last silently, which I think makes sense. The keyword arguments you pass in override keys from previous dicts (also good I think). The problem is that you can pass multiple duplicate keyword arguments, and the one below, which I think should succeed. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue2292 ___ -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue2292 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23285] PEP 475 - EINTR handling
Antoine Pitrou added the comment: The review diff is weird: it seems it contains changes that aren't EINTR-related (see e.g. argparse.rst). -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23285 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23199] libpython27.a in amd64 release is 32-bit
Zach Welch added the comment: That's certainly an interesting data point. We are just beginning to use MinGW-w64 internally, so I do not have enough experience to confirm or deny that advice. For various reasons, we must use cross-compiling on a Linux host, so the advice to use a native compiler is moot for our situation. Certainly, documenting the absense of the 64-bit library would be good. Providing a documented script to generate one is better. Providing the library would be ideal, if there will not be forward compatibility or runtime issues. It would be nice to see concrete details about the current state of affairs. The cython project's warning would carry more weight with me if it contained links to specific details: mailing list discussion that led to the deliberate decision to omit the 64-bit library, bug reports filed against the mingw-w64 project about the runtime issues, etc.. That said, such details probably do exist, but my cursory searching has failed to turn them up. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23199 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23285] PEP 475 - EINTR handling
Ned Deily added the comment: (It may be several days before I can spend much time on it but I will take a look.) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23285 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23095] [Windows] asyncio: race condition when cancelling a _WaitHandleFuture
Changes by STINNER Victor victor.stin...@gmail.com: -- title: asyncio: race condition when cancelling a _WaitHandleFuture - [Windows] asyncio: race condition when cancelling a _WaitHandleFuture ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23095 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Re: Trees
In article d34dbfbe-fe82-47dc-8bc3-c8773e2b7...@googlegroups.com, rustompm...@gmail.com says... Yeah python has trees alright. Heres' some simple tree-code Didn't you just demonstrate that Python has no trees and instead you have to implement them yourself (or use a third-party implementation)? I don't know what's the point of all this vain and misleading play with words. Not only most languages don't implement trees in their standard libraries (its no shame, it's no sin), but also it's quite evident that there's a big difference between implementing a data structure yourself through the application of language facilities and seeing that data structure already implemented for you in the standard library. -- https://mail.python.org/mailman/listinfo/python-list
[issue23284] curses, readline, tinfo, and also --prefix, dbm, CPPFLAGS
New submission from Poor Yorick: Building Python-2.7.9 using --prefix, with an ncurses that's linked to libtinfo and a readline that isn't linked to any termcap library, I ran into the trouble that the curses module wan't buing build with the needed -L and -l flags for the libtinfo shared object. I dug into setup.py, and ended up overhauling the readline, curses, and also dbm handling (more on that in another ticket). I also made changes to allow setup.py to pick up options like -isystem from $CPPFLAGS, replacing in the process the optparse module with the argparse module. Since argparse requires collections.OrderedDict, which isn't yet built at this stage, I added Lib_boot/argparse_boot.py, which uses the pure-Python OrderedDict from https://pypi.python.org/pypi/ordereddict and had setup.py use argparse_boot module instead. The build also ran into trouble with system directories that setup.py explicitly adds to inc_dirs and lib_dirs ahead of those of the alternate prefix. The attached files fixed all these issues in my scenario, allowing a succesful build and install of Python-2.7.9. -- components: Build hgrepos: 290 messages: 234399 nosy: pooryorick priority: normal severity: normal status: open title: curses, readline, tinfo, and also --prefix, dbm, CPPFLAGS versions: Python 2.7 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23284 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue2292] Missing *-unpacking generalizations
Neil Girdhar added the comment: Why is that correct? The PEP mentions overriding. Right now each dict overrides values from the last silently, which I think makes sense. The keyword arguments you pass in override keys from previous dicts (also good I think). The problem is that you can pass multiple duplicate keyword arguments, and the one below, which I think should succeed. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue2292 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue2292] Missing *-unpacking generalizations
Neil Girdhar added the comment: That makes sense. If you wanted to override, you could always write: f(**{**a, **b, 'x': 5}) rather than f(**a, **b, x=5) Should I go ahead and fix it so that overriding is always wrong? E.g., f(**{'x': 3}, **{'x': 4}) which currently works? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue2292 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue2292] Missing *-unpacking generalizations
Neil Girdhar added the comment: Could you try this and tell me how many BUILD_MAPs you're doing? dis.dis(def f(w, x, y, z, r): pass\nf(w=1, **{'x': 2}, y=3, z=4, r=5)) Mine does 2. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue2292 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue2292] Missing *-unpacking generalizations
Neil Girdhar added the comment: Thanks. It's probably compile.c under /* Same dance again for keyword arguments */. nseen remains zero and probably shouldn't. I need to learn more about the opcodes. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue2292 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23208] asyncio: add BaseEventLoop._current_handle
STINNER Victor added the comment: @Guido, @Yury: What do you think of this feature? Does it make sense to expose (internally) the handle currently executed? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23208 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23208] asyncio: add BaseEventLoop._current_handle
Yury Selivanov added the comment: What do you think of this feature? Does it make sense to expose (internally) the handle currently executed? I think it's OK to have something like `loop._current_handle` to work ~only~ in debug mode. Enhancing `loop.call_exception_handler` to use it also makes sense. I would also want to make sure, that this property exists only in debug mode and shouldn't be used outside of asyncio. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23208 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23199] libpython27.a in amd64 release is 32-bit
Steve Dower added the comment: Just came across this advice on https://github.com/cython/cython/wiki/64BitCythonExtensionsOnWindows: Do not use MinGW-w64. As you will notice, the MinGW import library for Python (e.g. libpython27.a) is omitted from the AMD64 version of Python. This is deliberate. Do not try to make one using dlltool. There is no official MinGW-w64 release yet, it is still in beta and considered unstable, although you can get a 64-bit build from e.g. TDM-GCC. There have also been issues with the mingw runtime conflicting with the MSVC runtime; this can happen from places you don't expect, such as inside runtime libraries for g++ or gfortran. To stay on the safe side, avoid MinGW-w64 for now. How accurate is this? Would we be better to omit the mingw libraries from the installer and instead provide the commands (or even a shell script?) to generate it with whatever toolset you're currently using? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23199 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue2292] Missing *-unpacking generalizations
Joshua Landau added the comment: 2 here as well: 15 LOAD_CONST 2 ('w') 18 LOAD_CONST 3 (1) 21 BUILD_MAP1 24 LOAD_CONST 4 (2) 27 LOAD_CONST 5 ('x') 30 STORE_MAP 31 BUILD_MAP1 34 LOAD_CONST 6 (3) 37 LOAD_CONST 7 ('y') 40 STORE_MAP 41 LOAD_CONST 8 (4) 44 LOAD_CONST 9 ('z') 47 STORE_MAP 48 LOAD_CONST 10 (5) 51 LOAD_CONST 11 ('r') 54 STORE_MAP 55 BUILD_MAP_UNPACK 2 -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue2292 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22947] Enable 'imageop' - Multimedia Srvices Feature module for 64-bit platform
Changes by koobs koobs.free...@gmail.com: -- nosy: +koobs ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22947 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Re: python traceroute
On Tue, 20 Jan 2015 19:37:26 -0800, Chandrakant Tiwari wrote: in the program below i want it to make it work the same way as TRACERT command . but i am not able to make it work the same way . for which i need your help thank you What is the difference between TRACERT and your Python script? What do you expect your script to do that it doesn't do, or what does it do that it shouldn't do? Please be explicit: # Wrong, don't do this. Program should work just like TRACERT. # A little better, but still wrong. Program should work just like TRACERT on operating system Foo version 7 when running this command: tracert -options argument # Better. I tried to do SOME TASK where I expected to get THESE RESULTS which matches this TRACERT command COMMAND on OPERATING SYSTEM, but instead I got THESE UNWANTED RESULTS. Otherwise, we have to: - guess what results you want - guess what results you got - guess what causes the wrong results - guess what changes you need to make -- Steve -- https://mail.python.org/mailman/listinfo/python-list
[issue23283] Backport Tools/clinic to 3.4
Larry Hastings added the comment: I would prefer the backport be more selective. There are other changes (set literals, fix --converters) in trunk that aren't in 3.4 and I wouldn't want them pulled in willy-nilly. However, I'd accept this backport if the patch looks minimal and clean. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23283 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13299] namedtuple row factory for sqlite3
YoSTEALTH added the comment: note: sqlite_namedtuplerow.patch _cache method conflicts with attached database with say common table.column name like id Using namedtuple method over sqlite3.Row was a terrible idea for me. I thought namedtuple is like tuple so should be faster then dict! wrong. I wasted 2 days change my work to namedtuple and back to sqlite3.Row, the speed difference on my working project was: namedtuple 0.035s/result sqlite3.Rows 0.0019s/result for(speed test) range: 1 namedtuple 17.3s sqlite3.Rows 0.4s My solution was to use sqlite3.Row (for speed) but to get named like usage by convert dict keys() with setattr names: class dict2named(dict): def __init__(self, *args, **kwargs): super(dict2named, self).__init__(*args, **kwargs) self.__dict__ = self Usage: for i in con.execute('SELECT * FROM table'): yield dict2named(i) Now i can use: print(i.title) and handy dict methods for dash column names: print(i['my-title']) print(i.get('my-title', 'boo')) Now working project speed: sqlite3.Rows 0.0020s/result for(speed test) range: 1 sqlite3.Rows 0.8s with dict2named converting This i can work with, tiny compromise in speed with better usage. -- nosy: +YoSTEALTH ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13299 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com