[issue34535] queue.Queue(timeout=0.001) avg delay Windows:14.5ms, Ubuntu: 0.063ms

2018-08-29 Thread Josh Rosenberg
Josh Rosenberg added the comment: Victor, that was a little overboard. By that logic, there doesn't need to be a Windows version of Python. That said, Paul doesn't seem to understand that the real resolution limit isn't 1 ms; that's the lower limit on arguments to t

[issue34574] OrderedDict iterators are exhausted during pickling

2018-09-05 Thread Josh Rosenberg
Josh Rosenberg added the comment: This would presumably be a side-effect of all generic pickling operations of iterators; figuring out what the iterator produces requires running out the iterator. You could special case it case-by-case, but that just makes the behavior unreliable/confusing

[issue34601] Typo: "which would rather raise MemoryError than give up", than or then?

2018-09-07 Thread Josh Rosenberg
Josh Rosenberg added the comment: "than" is correct; "giving up" in this context would mean "not even trying to allocate the memory and just preemptively raising OverflowError, like non-integer numeric types with limited ranges". Rather than giving up that way,

[issue34750] locals().update doesn't work in Enum body, even though direct assignment to locals() does

2018-09-21 Thread Josh Rosenberg
Josh Rosenberg added the comment: The documentation for locals ( https://docs.python.org/3/library/functions.html#locals ) specifically states: Note: The contents of this dictionary should not be modified; changes may not affect the values of local and free variables used by the interpreter

[issue34784] Heap-allocated StructSequences

2018-10-03 Thread Josh Rosenberg
Josh Rosenberg added the comment: This looks like a duplicate of #28709, though admittedly, that bug hasn't seen any PRs. -- nosy: +josh.r ___ Python tracker <https://bugs.python.org/is

[issue34886] subprocess.run throws exception when input and stdin are passed as kwargs

2018-10-03 Thread Josh Rosenberg
Josh Rosenberg added the comment: I just tried: subprocess.run('ls', input=b'', stdin=None) and I got the same ValueError as for passing using kwargs. Where did you get the idea subprocess.run('ls', input=b'', stdin

[issue34886] subprocess.run throws exception when input and stdin are passed as kwargs

2018-10-03 Thread Josh Rosenberg
Josh Rosenberg added the comment: The actual code receives input by name, but stdin is received in **kwargs. The test is just: if input is not None: if 'stdin' in kwargs: raise ValueError(...) kwargs['stdin'] = PIPE Perhaps just change `

[issue34889] int.to_bytes and int.from_bytes should default to the system byte order like the struct module does

2018-10-03 Thread Josh Rosenberg
Josh Rosenberg added the comment: to_bytes and from_bytes aren't remotely related to native primitive types, struct is. If the associated lengths aren't 2, 4 or 8, there is no real correlation with system level primitives, and providing these defaults makes it easy to accidentally

[issue19270] Document that sched.cancel() doesn't distinguish equal events and can break order

2018-10-09 Thread Josh Rosenberg
Josh Rosenberg added the comment: Victor: "I would be interested of the same test on Windows." Looks like someone performed it by accident, and filed #34943 in response (because time.monotonic() did in fact return the exact same time twice in a row

[issue34947] inspect.getclosurevars() does not get all globals

2018-10-09 Thread Josh Rosenberg
Josh Rosenberg added the comment: Problem: The variables from the nested functions (which comprehensions are effectively a special case of) aren't actually closure variables for the function being inspected. Allowing recursive identification of all closure variables might be helpf

[issue35006] itertools.combinations has wrong type when using the typing package

2018-10-16 Thread Josh Rosenberg
Josh Rosenberg added the comment: Looks like a bug in the typeshed (which mypy depends on to provide typing info for most of the stdlib, which isn't explicitly typed). Affects both combinations and combinations_with_replacement from a quick check of the code: https://github.com/p

[issue35043] functools.reduce doesn't work properly with itertools.chain

2018-10-22 Thread Josh Rosenberg
Josh Rosenberg added the comment: Your example code doesn't behave the way you claim. my_list isn't changed, and `a` is a chain generator, not a list (without a further list wrapping). In any event, there is no reason to involve reduce here. chain already handles varargs what you

[issue35046] logging.StreamHandler performs two syscalls when one would do

2018-10-22 Thread Josh Snyder
New submission from Josh Snyder : logging.StreamHandler contains the following code: stream.write(msg) stream.write(self.terminator) stream.flush() When sys.stderr (or whatever other stream) is unbuffered, this results in two system calls and allows log records from different

[issue35046] logging.StreamHandler performs two syscalls when one would do

2018-10-22 Thread Josh Snyder
Change by Josh Snyder : -- keywords: +patch pull_requests: +9381 stage: -> patch review ___ Python tracker <https://bugs.python.org/issue35046> ___ ___ Py

[issue35043] functools.reduce doesn't work properly with itertools.chain

2018-10-23 Thread Josh Rosenberg
Josh Rosenberg added the comment: Blech. Copy'n'paste error in last post: a = list(itertools.chain.from_iterable(*my_list)) should be: a = list(itertools.chain.from_iterable(my_list)) (Note removal of *, which is the whole point of fro

[issue35098] Deleting __new__ does not restore previous behavior

2018-10-30 Thread Josh Rosenberg
Change by Josh Rosenberg : -- resolution: -> duplicate stage: -> resolved status: open -> closed superseder: -> Assigning and deleting __new__ attr on the class does not allow to create instances of this class ___ Python tra

[issue35114] ssl.RAND_status docs describe it as returning True/False; actually returns 1/0

2018-10-30 Thread Josh Rosenberg
New submission from Josh Rosenberg : The ssl.RAND_status online docs say (with code format on True/False): "Return True if the SSL pseudo-random number generator has been seeded with ‘enough’ randomness, and False otherwise." This is incorrect; the function actually returns 1 or

[issue35175] Builtin function all() is handling dict() types in a weird way.

2018-11-06 Thread Josh Rosenberg
Change by Josh Rosenberg : -- resolution: -> not a bug stage: -> resolved status: open -> closed ___ Python tracker <https://bugs.python.or

[issue35180] Ctypes segfault or TypeError tested for python2.7 and 3

2018-11-06 Thread Josh Rosenberg
Josh Rosenberg added the comment: The TypeError on Py3 would be because functions taking c_char_p need bytes-like objects, not str, on Python 3. '%s' % directory is pointless when directory is a str; instead you need to encode it to a bytes-like object, e.g. opendir(os.fsencode

[issue35180] Ctypes segfault or TypeError tested for python2.7 and 3

2018-11-06 Thread Josh Rosenberg
Josh Rosenberg added the comment: As soon as you use ctypes, you sign up for all the security vulnerabilities, including denial of service, buffer overrun, use-after-free, etc. that plain old C programs are subject to. In this case, it's just a NULL pointer dereference (read: segfau

[issue35182] Popen.communicate() breaks when child closes its side of pipe but not exits

2018-11-07 Thread Josh Rosenberg
Josh Rosenberg added the comment: Sounds like the solution you'd want here is to just change each if check in _communicate, so instead of: if self.stdout: selector.register(self.stdout, selectors.EVENT_READ) if self.stderr: selector.register(self.s

[issue35182] Popen.communicate() breaks when child closes its side of pipe but not exits

2018-11-07 Thread Josh Rosenberg
Josh Rosenberg added the comment: Hmm... Correction to my previous post. communicate itself has a test for: "if self._communication_started and input:" that raises an error if it passes, so the second call to communicate can only be passed None/empty input. And _communicate only

[issue34805] Explicitly specify `MyClass.__subclasses__()` returns classes in definition order

2018-11-07 Thread Josh Rosenberg
Josh Rosenberg added the comment: First off, the OP's original case seems like a use case for functools.singledispatch. Not really related to the problem, just thought I'd mention it. Secondly, are we sure we want to make such a guarantee? That restricts the underlying storage

[issue34805] Explicitly specify `MyClass.__subclasses__()` returns classes in definition order

2018-11-07 Thread Josh Rosenberg
Josh Rosenberg added the comment: I'm also a little skeptical of the OP's proposed use case for other reasons. In any circumstance other than "all classes are defined in the same module", you can't really make useful guarantees about subclass definition order, becau

[issue34805] Explicitly specify `MyClass.__subclasses__()` returns classes in definition order

2018-11-07 Thread Josh Rosenberg
Josh Rosenberg added the comment: I wrote the response to the OP's use case before I saw your response; it wasn't really intended as an additional critique of the proposed change or a counterargument to your post, just a note that the required behavior could be obtained on all v

[issue34805] Explicitly specify `MyClass.__subclasses__()` returns classes in definition order

2018-11-07 Thread Josh Rosenberg
Josh Rosenberg added the comment: Keep in mind, had this guarantee been in place in 3.4, the improvement in 3.5 couldn't have been made, and issue17936 might have been closed and never addressed, even once dicts were ordered, simply because we never rechecked it. It makes the

[issue15818] multiprocessing documentation of Process.exitcode

2012-08-29 Thread Josh Kupershmidt
New submission from Josh Kupershmidt: [I tried to send this as an email to d...@python.org yesterday, but it seems to have gotten eaten, as I don't see the message in the archives.] Hi all, The documentation for the multiprocessing module claims: | Note that the start(), join(), is_

[issue20895] Add bytes.empty_buffer and deprecate bytes(17) for the same purpose

2014-03-14 Thread Josh Rosenberg
Josh Rosenberg added the comment: I would think the argument for deprecation is that usually, people type bytes(7) or bytes(somesmallintvalue) expecting to create a length one bytes object using that value (happens by accident if you iterate a bytes object and forget it's an iterable of

[issue20895] Add bytes.empty_buffer and deprecate bytes(17) for the same purpose

2014-03-14 Thread Josh Rosenberg
Josh Rosenberg added the comment: Terry: You forgot to use a raw string for your timeit.repeat check, which is why it blew up. It was evaluating the \0 when you defined the statement string itself, not the contents. If you use r'b"\0" * 7' it works just fine by deferr

[issue19995] %c, %o, %x, %X accept non-integer values instead of raising an exception

2014-03-19 Thread Josh Rosenberg
Changes by Josh Rosenberg : -- nosy: +josh.rosenberg ___ Python tracker <http://bugs.python.org/issue19995> ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue20992] reading individual bytes of multiple binary files using the Python module fileinput

2014-03-24 Thread Josh Rosenberg
Josh Rosenberg added the comment: fileinput's semantics are heavily tied to lines, not bytes. And processing binary files byte by byte is rather inefficient; can you explain why this feature would be of general utility such that it would be worth including it in the standard library?

[issue20992] reading individual bytes of multiple binary files using the Python module fileinput

2014-03-24 Thread Josh Rosenberg
Josh Rosenberg added the comment: That example should have included mode="rb" when using fileinput.input(); oops. Pretend I didn't forget it. -- ___ Python tracker <http://bugs.pyt

[issue20992] reading individual bytes of multiple binary files using the Python module fileinput

2014-03-24 Thread Josh Rosenberg
Josh Rosenberg added the comment: On memory: Yeah, it could be if the file didn't include any newline characters. Same problem could apply if a text input file relied on word wrap in an editor and included very few or no newlines itself. There are non-fileinput ways of doing this, like I

[issue20992] reading individual bytes of multiple binary files using the Python module fileinput

2014-03-24 Thread Josh Rosenberg
Josh Rosenberg added the comment: And of course, missed another typo. open's first arg should be file, not filename. -- ___ Python tracker <http://bugs.python.org/is

[issue21056] csv documentation is incorrect

2014-03-25 Thread Josh Rosenberg
Josh Rosenberg added the comment: Aside from the method being named __next__(), it's the same flaw in all copies of the Py3 documentation. I don't think explicitly enumerating types is the way to go though. I'd just remove the documentation for __next__, and leave it up

[issue21011] PyArg_ParseTupleAndKeywords doesn't take const char *keywords[]

2014-03-25 Thread Josh Rosenberg
Josh Rosenberg added the comment: This has come up before. Links to additional info: https://mail.python.org/pipermail/python-dev/2006-February/060689.html http://bugs.python.org/issue1772673 -- nosy: +josh.rosenberg ___ Python tracker <h

[issue21067] Support Multiple finally clauses.

2014-03-25 Thread Josh Rosenberg
Josh Rosenberg added the comment: And for this particular case, even if the resource allocators don't support the context manager protocol, contextlib.closing can do the job: from contextlib import closing with closing(allocateresource1()) as resource1, closing(allocatereso

[issue20739] PEP 463 (except expression) implementation

2014-03-27 Thread Josh Rosenberg
Josh Rosenberg added the comment: It's not part of the PEP, but what happens with the new syntax if there is an existing exception context? Some utilities (e.g. functools.lru_cache) use dict.get over a try/except because they operate under the assumption that they may be invoked with

[issue21075] fileinput should use stdin.buffer for "rb" mode

2014-03-27 Thread Josh Rosenberg
Josh Rosenberg added the comment: There is a similar, (unfixed?) bug, #14156, in argparse as well. Seems like a common failing in the move to Python 3; std*.buffer was introduced, but none of the places that use it were updated, so they all became str only. -- nosy: +josh.rosenberg

[issue14156] argparse.FileType for '-' doesn't work for a mode of 'rb'

2014-03-27 Thread Josh Rosenberg
Changes by Josh Rosenberg : -- nosy: +josh.rosenberg ___ Python tracker <http://bugs.python.org/issue14156> ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue20895] Add bytes.empty_buffer and deprecate bytes(17) for the same purpose

2014-03-28 Thread Josh Rosenberg
Josh Rosenberg added the comment: Why would we need bytes.fill(length, value)? Is b'\xVV' * length (or if value is a variable containing int, bytes((value,)) * length) unreasonable? Similarly, bytearray(b'\xVV) * length or bytearray((value,)) * length is both Pythonic and p

[issue21101] Extend the PyDict C API to handle cases where the hash value is known

2014-03-31 Thread Josh Rosenberg
Changes by Josh Rosenberg : -- nosy: +josh.rosenberg ___ Python tracker <http://bugs.python.org/issue21101> ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue21118] str.translate is absurdly slow in majority of use cases (takes 3x to 10x longer than similar functions)

2014-03-31 Thread Josh Rosenberg
New submission from Josh Rosenberg: String translation functions, at least in other languages, are typically a performance optimization when you *really* need the speed. In exchange for paying the memory cost and one-time work to create a translation table, you get much faster 1 to 1 and

[issue21118] str.translate is absurdly slow in majority of use cases (takes up to 60x longer than similar functions)

2014-03-31 Thread Josh Rosenberg
Changes by Josh Rosenberg : -- title: str.translate is absurdly slow in majority of use cases (takes 3x to 10x longer than similar functions) -> str.translate is absurdly slow in majority of use cases (takes up to 60x longer than similar functi

[issue21118] str.translate is absurdly slow in majority of use cases (takes up to 60x longer than similar functions)

2014-04-01 Thread Josh Rosenberg
Josh Rosenberg added the comment: @haypo: Are you planning to run with this then? Or shall I pick up where your patch leaves off? Thanks for the pointer to the codecs charmap_build; it's not documented anywhere that I can tell, so I didn't even know it existed. Now to dig into the

[issue21118] str.translate is absurdly slow in majority of use cases (takes up to 60x longer than similar functions)

2014-04-03 Thread Josh Rosenberg
Josh Rosenberg added the comment: Hmm... Maybe I'm testing it wrong, but I'm finding your patch is slowing down translation by a small amount on my test case; not a lot, maybe a 10% slowdown on enlarging translations, 6% for 1-1, and deletion

[issue21118] str.translate is absurdly slow in majority of use cases (takes up to 60x longer than similar functions)

2014-04-06 Thread Josh Rosenberg
Josh Rosenberg added the comment: Thanks for addressing this so fast. Annoyingly, I suspect it will not help the original case that led me to finding the slowdown (I had some code that was translating from 56 latin-1 Romance characters with diacritics to the equivalent ASCII characters, so it

[issue21165] Optimize str.translate() for replacement with substrings and non-ASCII strings

2014-04-07 Thread Josh Rosenberg
Changes by Josh Rosenberg : -- nosy: +josh.rosenberg ___ Python tracker <http://bugs.python.org/issue21165> ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue21175] Refcounting error in str.translate fastpath

2014-04-07 Thread Josh Rosenberg
New submission from Josh Rosenberg: Py_None is not being properly decref-ed in the str.translate fast path. I've attached a simple patch that fixes this (also corrects some comments and types in the same function). No idea is Py_None ref leaks are considered a serious problem, but I f

[issue21175] Refcounting error in str.translate fastpath

2014-04-07 Thread Josh Rosenberg
Josh Rosenberg added the comment: For reference, bug introduced by fix for #21118. -- ___ Python tracker <http://bugs.python.org/issue21175> ___ ___ Python-bug

[issue21175] Refcounting error in str.translate fastpath

2014-04-07 Thread Josh Rosenberg
Josh Rosenberg added the comment: Also, just to be clear, I submitted the contributor form earlier this evening (using the online submission tool), so as soon as that propagates, it should be possible to accept my code. -- ___ Python tracker <h

[issue16395] Documentation claims that PySequence_Fast returns a tuple, when it actually returns a list.

2014-04-07 Thread Josh Rosenberg
Josh Rosenberg added the comment: Any news on this? I was about to open a bug of my own for this, since the docs and code are still out of sync. -- nosy: +josh.rosenberg ___ Python tracker <http://bugs.python.org/issue16

[issue16395] Documentation claims that PySequence_Fast returns a tuple, when it actually returns a list.

2014-04-07 Thread Josh Rosenberg
Josh Rosenberg added the comment: As far as performance goes, presumably the length hinting API reduces the number of cases in which we're working with completely unsized iterables, right? -- ___ Python tracker <http://bugs.python.org/is

[issue9066] Standard type codes for array.array, same as struct

2014-04-08 Thread Josh Rosenberg
Changes by Josh Rosenberg : -- nosy: +josh.rosenberg ___ Python tracker <http://bugs.python.org/issue9066> ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue21179] Rounding half to even

2014-04-08 Thread Josh Rosenberg
Josh Rosenberg added the comment: Python 3.2-3.4 (probably all of 3.x) use round half even, but testing 2.7.3 on Ubuntu confirms what you say. In terms of the decimal constants, Py2.7 round() appears to use decimal.ROUND_HALF_UP behavior while 3.x uses decimal.ROUND_HALF_EVEN behavior. Looks

[issue20539] math.factorial may throw OverflowError

2014-04-09 Thread Josh Rosenberg
Josh Rosenberg added the comment: Mark, you said: > OverflowError seems to have the majority vote. I'll change it to that. But your most recent patch seems to have gone back to ValueError for both cases. Is there a reason for that? FWIW, I favor OverflowError as the "too large&

[issue21185] heapq fails to print in sorted order for certain inputs

2014-04-09 Thread Josh Rosenberg
Josh Rosenberg added the comment: It's not really relevant what a heapified list looks like (and there is no reason to guarantee a particular appearance, since it's an implementation detail that could change). It's supposed to function as a heap with the heap functions, that&

[issue21185] heapq fails to print in sorted order for certain inputs

2014-04-09 Thread Josh Rosenberg
Josh Rosenberg added the comment: By the way, in the top answer to the Stack Overflow post you linked, it's clear that the list wasn't sorted. [44, 42, 3, 89, 10] became [3, 10, 44, 89, 42], and you'll notice, the last three elements a

[issue20539] math.factorial may throw OverflowError

2014-04-09 Thread Josh Rosenberg
Josh Rosenberg added the comment: I just think it's a little odd to make math.factorial uniquely sensitive to the documented definition of OverflowError. Basically every one of the non-masking PyLong_As interfaces uses OverflowError for too large values. In fact, all the functions whic

[issue21193] pow(a, b, c) should not raise TypeError when b is negative and c is provided

2014-04-09 Thread Josh Rosenberg
New submission from Josh Rosenberg: While checking the exceptions used to compare existing behavior while investigating #20539, I noticed a weird behavior in pow() (implemented by long_pow in longobject.c). If a 3rd argument (the modulus) is provided, and the 2nd argument (the exponent) is

[issue20539] math.factorial may throw OverflowError

2014-04-09 Thread Josh Rosenberg
Josh Rosenberg added the comment: A few examples (some are patently ridiculous, since the range of values anyone would use ends long before you'd overflow a 32 bit integer, let alone a 64 bit value on my build of Python, but bear with me: >>> datetime.datetime(2**64, 1, 2) T

[issue21193] pow(a, b, c) should not raise TypeError when b is negative and c is provided

2014-04-09 Thread Josh Rosenberg
Josh Rosenberg added the comment: Here's the trivial patch for code and the associated unit test (we were actually testing that it raised TypeError specifically; it now raises ValueError, and the unit test expects ValueError). unit tests passed aside from test_io, but I'm pretty s

[issue21193] pow(a, b, c) should not raise TypeError when b is negative and c is provided

2014-04-09 Thread Josh Rosenberg
Josh Rosenberg added the comment: As I mentioned on another bug, I filled out and submitted the contributor agreement form electronically earlier this week, it just hasn't propagated yet. I'm fairly sure trained monkeys reading the description of this bug report would produce the

[issue21193] pow(a, b, c) should not raise TypeError when b is negative and c is provided

2014-04-10 Thread Josh Rosenberg
Josh Rosenberg added the comment: Agreed that there is no need to patch 2.7/3.4; this is a pedantic correctness fix, not a serious bug. -- ___ Python tracker <http://bugs.python.org/issue21

[issue21208] Change default behavior of arguments with type bool when options are specified

2014-04-12 Thread Josh Rosenberg
Josh Rosenberg added the comment: If your goal is to get a boolean on/off switch, that's what action='store_true' is for. You don't need to specify nargs or type at all; using bool as the type means it wants an argument, and will pass the string form of the argument to

[issue21199] Python on 64-bit Windows uses signed 32-bit type for read length

2014-04-13 Thread Josh Rosenberg
Josh Rosenberg added the comment: So it predates the existence of type code 'n', which would be the appropriate type code, but no one updated it. Antoine: Inability to perform a 2GB+ read properly is not something that should be worked around on a case by case basis. Th

[issue21233] Add *Calloc functions to CPython memory allocation API

2014-04-15 Thread Josh Rosenberg
Changes by Josh Rosenberg : -- nosy: +josh.rosenberg ___ Python tracker <http://bugs.python.org/issue21233> ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue21233] Add *Calloc functions to CPython memory allocation API

2014-04-15 Thread Josh Rosenberg
Josh Rosenberg added the comment: General comment on patch: For the flag value that toggles zero-ing, perhaps use a different name, e.g. setzero, clearmem, initzero or somesuch instead of calloc? calloc already gets used to refer to both the C standard function and the function pointer

[issue21233] Add *Calloc functions to CPython memory allocation API

2014-04-15 Thread Josh Rosenberg
Josh Rosenberg added the comment: Additional comment on clarity: Might it make sense to make the calloc structure member take both the num and size arguments that the underlying calloc takes? That is, instead of: void* (*calloc) (void *ctx, size_t size); Declare it as: void* (*calloc) (void

[issue21233] Add *Calloc functions to CPython memory allocation API

2014-04-15 Thread Josh Rosenberg
Josh Rosenberg added the comment: Sorry for breaking it up, but the same comment on consistent prototypes mirroring the C standard lib calloc would apply to all the API functions as well, e.g. PyMem_RawCalloc, PyMem_Calloc, PyObject_Calloc and _PyObject_GC_Calloc, not just the structure

[issue16991] Add OrderedDict written in C

2014-04-15 Thread Josh Rosenberg
Changes by Josh Rosenberg : -- nosy: +josh.rosenberg ___ Python tracker <http://bugs.python.org/issue16991> ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue21237] Update Python 2/3 porting HOWTO's suggestion for dealing with map()

2014-04-16 Thread Josh Rosenberg
Josh Rosenberg added the comment: I think the suggestion is intended for "how do I keep Python 2 semantics in Python 3?", not "how can I write my Python 2 code so it will run equivalently in Python 3?" It wouldn't be a bad idea to point out that you can adopt Py3 sema

[issue21233] Add *Calloc functions to CPython memory allocation API

2014-04-17 Thread Josh Rosenberg
Josh Rosenberg added the comment: Julian: No. See the diff: http://bugs.python.org/review/21233/diff/11644/Objects/typeobject.c The original GC_Malloc was explicitly memset-ing after confirming that it received a non-NULL pointer from the underlying malloc call; that memset is removed in

[issue21233] Add *Calloc functions to CPython memory allocation API

2014-04-17 Thread Josh Rosenberg
Josh Rosenberg added the comment: Well, to be more specific, PyType_GenericAlloc was originally calling one of two methods that didn't zero the memory (one of which was GC_Malloc), then memset-ing. Just realized you're talking about something else; not sure if you're correct

[issue21279] str.translate documentation incomplete

2014-04-17 Thread Josh Rosenberg
Josh Rosenberg added the comment: For the record, I have intentionally used bytes.maketrans to make translation table for str.translate for precisely this reason; it's much faster to look up a ordinal in a bytes object than in a dictionary. Before the recent (partial) patch for str.tran

[issue21308] PEP 466: backport ssl changes

2014-04-18 Thread Josh Rosenberg
Changes by Josh Rosenberg : -- nosy: +josh.rosenberg ___ Python tracker <http://bugs.python.org/issue21308> ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue21305] PEP 466: update os.urandom

2014-04-18 Thread Josh Rosenberg
Changes by Josh Rosenberg : -- nosy: +josh.rosenberg ___ Python tracker <http://bugs.python.org/issue21305> ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue21314] Bizarre help

2014-04-20 Thread Josh Rosenberg
Josh Rosenberg added the comment: I don't know about the other bits, but that trailing '/' is how Argument Clinic (which makes full featured inspection available to built-in functions) notes that the parameters are positional only, and cannot be passed by keyword. See PEP436.

[issue17552] socket.sendfile()

2014-04-21 Thread Josh Rosenberg
Josh Rosenberg added the comment: For TransmitFile support, the Windows function to turn an integer file descriptor into a WinAPI file HANDLE should be _get_osfhandle: http://msdn.microsoft.com/en-us/library/ks2530z6.aspx -- nosy: +josh.rosenberg

[issue21408] delegation of `!=` to the right-hand side argument is not always done

2014-05-01 Thread Josh Rosenberg
Josh Rosenberg added the comment: Why would an subclass of object that doesn't redefine either __eq__ or __ne__ have a different behavior for inequality than object itself? Bar never defined __eq__, so it shouldn't have an implicit __ne__ any more than object itself does... Sayin

[issue21419] Use calloc() instead of malloc() for int << int (lshift)

2014-05-02 Thread Josh Rosenberg
Josh Rosenberg added the comment: Looks like you forgot to actually use the use_calloc parameter you put in the long_alloc prototype. It accepts it, but it's never used or passed to another function. So right now, the only difference in behavior is that there is an extra layer of fun

[issue21419] Use calloc() instead of malloc() for int << int (lshift)

2014-05-02 Thread Josh Rosenberg
Josh Rosenberg added the comment: Given your benchmarks show improvements (you posted while I was typing my last comment), I'm guessing it's just the posted patch that's wrong, and your local changes actually use use_calloc? -- ___

[issue21419] Use calloc() instead of malloc() for int << int (lshift)

2014-05-02 Thread Josh Rosenberg
Josh Rosenberg added the comment: While you're doing this, might it make sense to add a special case to long_pow so it identifies cases where a (digit-sized) value with an absolute value equal to a power of 2 is being raised to a positive integer exponent, and convert said cases to equiv

[issue21419] Use calloc() instead of malloc() for int << int (lshift)

2014-05-02 Thread Josh Rosenberg
Josh Rosenberg added the comment: I swear, I need to refresh before I post a long comment. If this is slowing everything down a little just to make 1 << (2 ** 29) faster (and did you really mean 1 << (1 << 29) ? :-) ), th

[issue21419] Use calloc() instead of malloc() for int << int (lshift)

2014-05-02 Thread Josh Rosenberg
Josh Rosenberg added the comment: One possible way to salvage it: Have you considered declaring long_alloc as Py_LOCAL_INLINE, or, now that I've checked #5553, a macro for long_alloc, so it gets inlined, and doesn't add the check overhead to everything (since properly inlining with

[issue21419] Use calloc() instead of malloc() for int << int (lshift)

2014-05-02 Thread Josh Rosenberg
Josh Rosenberg added the comment: And now that I'm thinking about it, the probable cause of the slowdown is that, for any PyLongObject that's smaller than PAGESIZE (give or take), using Calloc means calloc is just calling memset to zero the PyLongObject header and the "used&qu

[issue21421] ABCs for MappingViews should declare __slots__ so subclasses aren't forced to have __dict__/__weakref__

2014-05-02 Thread Josh Rosenberg
New submission from Josh Rosenberg: Unlike the other collections ABCs, MappingView and its subclasses (Keys|Items|Values)View don't define __slots__, so users inheriting them to take advantage of the mix-in methods get a __dict__ and __weakref__, even if they try to avoid it by decl

[issue21421] ABCs for MappingViews should declare __slots__ so subclasses aren't forced to have __dict__/__weakref__

2014-05-02 Thread Josh Rosenberg
Josh Rosenberg added the comment: Hmm... First patch isn't generating a review diff (I'm guessing because my VM's time sync went farkakte). Trying again. -- Added file: http://bugs.python.org/file35142/slots_for_mappingview_abcs.patch ___

[issue21421] ABCs for MappingViews should declare __slots__ so subclasses aren't forced to have __dict__/__weakref__

2014-05-02 Thread Josh Rosenberg
Changes by Josh Rosenberg : Removed file: http://bugs.python.org/file35141/slots_for_mappingview_abcs.patch ___ Python tracker <http://bugs.python.org/issue21421> ___ ___

[issue21421] ABCs for MappingViews should declare __slots__ so subclasses aren't forced to have __dict__/__weakref__

2014-05-02 Thread Josh Rosenberg
Josh Rosenberg added the comment: I also wrote a slightly more thorough patch that simplifies some of the method implementations (largely just replacing a bunch of for/if/return True/False else return False/True with any/all calls against a generator expression). The one behavior difference

[issue21421] ABCs for MappingViews should declare __slots__ so subclasses aren't forced to have __dict__/__weakref__

2014-05-04 Thread Josh Rosenberg
Josh Rosenberg added the comment: Cool. Thanks for the feedback. I split it into two patches for a reason; I wasn't wedded to the simplification. -- ___ Python tracker <http://bugs.python.org/is

[issue21423] concurrent.futures.ThreadPoolExecutor should accept an initializer argument

2014-05-06 Thread Josh Rosenberg
Josh Rosenberg added the comment: Do you mean ProcessPoolExecutor? Thread based pools don't involve serialization. It would be good for ThreadPoolExecutor to have it as well, to make it easier to switch between executors, but only ProcessPoolExecutor is suffering from serialization ove

[issue21449] Replace _PyUnicode_CompareWithId with _PyUnicode_CompareWithIdEqual

2014-05-06 Thread Josh Rosenberg
New submission from Josh Rosenberg: _PyUnicode_CompareWithId is used exclusively for equality comparisons (after all, identifiers aren't really sortable in a meaningful way; they're isolated values, not a continuum). But because _PyUnicode_CompareWithId maintains the general

[issue21423] concurrent.futures.ThreadPoolExecutor should accept an initializer argument

2014-05-06 Thread Josh Rosenberg
Josh Rosenberg added the comment: I'm not a core developer, but writing the patch is usually considered helpful. Two notes: 1. Make sure to write unit tests for any new behavior 2. I'd suggest making any such argument keyword-only; if we move closer to the Java executor model,

[issue12556] Disable size checks in mmap.mmap()

2014-05-12 Thread Josh Triplett
Josh Triplett added the comment: This rejection is indeed problematic. If mmap.mmap receives an explicit size, checking that size against stat will break on devices or special files. It's perfectly reasonable that mmap.mmap's automatic logic when passed length=0 (to map the e

[issue21484] More clarity needed about difference between "x += e" and "x = x + e"

2014-05-12 Thread Josh Rosenberg
Josh Rosenberg added the comment: It seems to me like that is one of the most obvious consequences. How is this not an immediately obvious consequence? -- nosy: +josh.rosenberg ___ Python tracker <http://bugs.python.org/issue21

[issue21401] python2 -3 does not warn about str/unicode to bytes conversions and comparisons

2014-05-13 Thread Josh Cogliati
Josh Cogliati added the comment: Other than in the source code in Modules/main.c, is -b documented anywhere? (For 2.7.6, The html docs, man page, and --help all failed to mention it) -- nosy: +jrincayc ___ Python tracker <http://bugs.python.

[issue21507] set and frozenset constructor should use operator.length_hint to guess the size of the iterator

2014-05-14 Thread Josh Rosenberg
Josh Rosenberg added the comment: I think the argument against using PyObject_LengthHint for the general iterable case is that for inputs other than sets or dicts, the assumption is that significant deduplication will occur. With your patch, if I run: myset = frozenset([0] * 100) it will

[issue21508] C API PyArg_ParseTuple doc is innacurate

2014-05-14 Thread Josh Rosenberg
Josh Rosenberg added the comment: You'd prefer it say it returns 1 on success and 0 on failure? Or non-zero on success, zero on failure? Is true/false that bad? After all, C says 0 is false, all other integer values are true; phrasing it as zero vs. non-zero may be slightly more techni

[issue21513] speed up some ipaddress properties

2014-05-15 Thread Josh Rosenberg
Changes by Josh Rosenberg : -- nosy: +josh.rosenberg ___ Python tracker <http://bugs.python.org/issue21513> ___ ___ Python-bugs-list mailing list Unsubscribe:

<    1   2   3   4   5   6   7   8   9   >