[issue18920] argparse module version action

2013-09-04 Thread Wolfgang Maier
New submission from Wolfgang Maier: Hi, I just noticed that version output generated via the **'version' action** of the **argparse** module is routed to stderr. I'd expect regular output to go to stdout instead. The current behavior also seems inconsistent to me because --help prints to stdout

[issue20481] Clarify type coercion rules in statistics module

2014-02-01 Thread Wolfgang Maier
Wolfgang Maier added the comment: Thanks Nick for filing this! I've been working on modifications to statistics._sum and statistics._coerce_types that together make the module's behaviour independent of the order of input types (by making the decision based on the set of input types

[issue20481] Clarify type coercion rules in statistics module

2014-02-02 Thread Wolfgang Maier
Wolfgang Maier added the comment: Hi Oscar, well, I haven't used sympy much, and I have no experience with the others, but in light of your comment I quickly checked sympy and gmpy2. You are right about them still not using the numbers ABCs, however, on your advise I also checked how

[issue20479] Efficiently support weight/frequency mappings in the statistics module

2014-02-02 Thread Wolfgang Maier
Wolfgang Maier added the comment: -Ursprüngliche Nachricht- Von: Steven D'Aprano [mailto:rep...@bugs.python.org] Gesendet: Sonntag, 2. Februar 2014 12:55 An: wolfgang.ma...@biologie.uni-freiburg.de Betreff: [issue20479] Efficiently support weight/frequency mappings

[issue20479] Efficiently support weight/frequency mappings in the statistics module

2014-02-03 Thread Wolfgang Maier
Wolfgang Maier added the comment: Well, I was thinking about frequencies (ints) when suggesting for x,m in data.items(): T = _coerce_types(T, type(x)) n, d = exact_ratio(x) partials[d] = partials_get(d, 0) + n*m in my previous message. To support weights (float

[issue20481] Clarify type coercion rules in statistics module

2014-02-03 Thread Wolfgang Maier
Wolfgang Maier added the comment: there are currently two strict requirements for any numeric type to be usable with statistics._sum: I meant *three* of course (remembered one only during writing). -- ___ Python tracker rep...@bugs.python.org

[issue20481] Clarify type coercion rules in statistics module

2014-02-03 Thread Wolfgang Maier
Wolfgang Maier added the comment: Just to make sure that this discussion is not getting on the wrong track, there are currently two strict requirements for any numeric type to be usable with statistics._sum: (1) the type has to provide either - numerator/denominator properties

[issue20481] Clarify type coercion rules in statistics module

2014-02-03 Thread Wolfgang Maier
Wolfgang Maier added the comment: Once the input numbers are converted to float statistics._sum can handle them perfectly well. In this case I think the output should also be a float so that it's clear that precision may have been lost. If the precision of float is not what the user wants

[issue20481] Clarify type coercion rules in statistics module

2014-02-04 Thread Wolfgang Maier
Wolfgang Maier added the comment: Hi Nick and Oscar, my patch including tests is ready. What else should I say than that I think it is ok, but of course with only days remaining and still no feedback from Steven, I'm not sure there is any chance for it going into 3.4 still. Anyway, before

[issue20481] Clarify type coercion rules in statistics module

2014-02-04 Thread Wolfgang Maier
Wolfgang Maier added the comment: Hi Steven, sounds reasonable, still here's the patch in diff version. Its rules for type coercion are detailed in _coerce_types's docstring. Questions and comments are welcome. Best, Wolfgang -- keywords: +patch Added file: http://bugs.python.org

[issue20499] Rounding errors with statistics.variance

2014-02-07 Thread Wolfgang Maier
Wolfgang Maier added the comment: I have written a patch for this issue (I'm uploading the complete new code for everyone to try it - importing it into Python3.3 works fine; a diff with additional tests against Oscar's example will follow soon). Just as Oscar suggested, this new version

[issue20499] Rounding errors with statistics.variance

2014-02-07 Thread Wolfgang Maier
Wolfgang Maier added the comment: We can add a fast Decimal.as_integer_ratio() in C. That would be a terrific thing to have !! Currently, Decimals perform really poorly with the statistics functions and this is entirely due to this bottleneck. With regard to calculating the sum of Decimals

[issue20499] Rounding errors with statistics.variance

2014-02-07 Thread Wolfgang Maier
Wolfgang Maier added the comment: Ok, I finally managed to get the test suite right for this, so here is the patch diff for everything. I made a few final changes to the module itself (mostly to please the test suite), so I'll edited the complete code as well. -- keywords: +patch

[issue20499] Rounding errors with statistics.variance

2014-02-07 Thread Wolfgang Maier
Changes by Wolfgang Maier wolfgang.ma...@biologie.uni-freiburg.de: Added file: http://bugs.python.org/file33959/statistics.py ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20499

[issue20499] Rounding errors with statistics.variance

2014-02-07 Thread Wolfgang Maier
Wolfgang Maier added the comment: In principle, your approach using itertools.groupby, the existing _sum, your decimalsum, and my _ExactRatio class could be combined. You could call decimalsum for Decimal and subclasses, the current _sum for everything else. _sum would return an _ExactRatio

[issue20561] Decimal handling error in statistics module

2014-02-08 Thread Wolfgang Maier
New submission from Wolfgang Maier: Can this still be fixed in 3.4 ?? I came across this bug in the statistics module today: import statistics data = [Decimal('1e4')] statistics.mean(data) Traceback (most recent call last): File pyshell#465, line 1, in module statistics.mean(data

[issue20561] Decimal handling error in statistics module

2014-02-08 Thread Wolfgang Maier
Wolfgang Maier added the comment: #if type(den) != int: #print (d, sign, digits, exp, num, den) was inserted by me of course for debugging this. Forgot to take it out again. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org

[issue20561] Decimal handling error in statistics module

2014-02-08 Thread Wolfgang Maier
Changes by Wolfgang Maier wolfgang.ma...@biologie.uni-freiburg.de: -- nosy: +ncoghlan ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue20561

[issue20499] Rounding errors with statistics.variance

2014-02-08 Thread Wolfgang Maier
Wolfgang Maier added the comment: I worked out a slightly speedier version of decimal_to_ratio today (Stefan: that's when I duplicated your bug report): from decimal import Context def _decimal_to_ratio (x): _, digits, exp = x.as_tuple() if exp in _ExactRatio.decimal_infinite: # INF

[issue20499] Rounding errors with statistics.variance

2014-02-08 Thread Wolfgang Maier
Wolfgang Maier added the comment: oops, if exp in _ExactRatio.decimal_infinite: # INF, NAN, sNAN should read if exp in ('F', 'n', 'N'): # INF, NAN, sNAN of course. What I pasted comes from a micro-optimization I tried, but which doesn't give any benefit

[issue21146] update gzip usage examples in docs

2014-04-03 Thread Wolfgang Maier
New submission from Wolfgang Maier: The current documentation of the gzip module should have its section 12.2.1. Examples of usage updated to reflect the changes made to the module in Python3.2 (https://docs.python.org/3.2/whatsnew/3.2.html#gzip-and-zipfile). Currently, the recipe given

[issue21146] update gzip usage examples in docs

2014-04-03 Thread Wolfgang Maier
Wolfgang Maier added the comment: with open(src, 'rb') as f_in: with gzip.open(dst, 'wb') as f_out: shutil.copyfileobj(f_in, f_out) +1 !! exactly as fast as my suggestion (with compression and de-compression), but a lot clearer ! Hadn't thought

[issue21146] update gzip usage examples in docs

2014-04-03 Thread Wolfgang Maier
Wolfgang Maier added the comment: same speed is not surprising though as shutil.copyfileobj is implemented like this: def copyfileobj(fsrc, fdst, length=16*1024): copy data from file-like object fsrc to file-like object fdst while 1: buf = fsrc.read(length) if not buf

[issue21146] update gzip usage examples in docs

2014-04-08 Thread Wolfgang Maier
Wolfgang Maier added the comment: ok, I've prepared the patch using the elegant shutil solution. -- keywords: +patch Added file: http://bugs.python.org/file34765/gzip_example_usage_patch.diff ___ Python tracker rep...@bugs.python.org http

[issue21184] statistics.pvariance with known mean does not work as expected

2014-04-09 Thread Wolfgang Maier
Wolfgang Maier added the comment: I do not think this is a bug in the module, but rather incorrect usage. From your own docs: data should be an iterable of Real-valued numbers, with at least one value. The optional argument mu, if given, should be the mean of the data

[issue21184] statistics.pvariance with known mean does not work as expected

2014-04-09 Thread Wolfgang Maier
Wolfgang Maier added the comment: ok, there may be use cases for calculating a variance estimate in such situations, but IMHO what you are trying to do is to abuse a function which is not documented to be made for the purpose and then complain that it does not behave correctly

[issue21204] published examples don't work

2014-04-12 Thread Wolfgang Maier
Changes by Wolfgang Maier wolfgang.ma...@biologie.uni-freiburg.de: -- nosy: +wolma ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21204

[issue21146] update gzip usage examples in docs

2014-04-15 Thread Wolfgang Maier
Wolfgang Maier added the comment: well, buffering is not the issue here. It's that the file iterator used in the current example is line-based, so whatever the buffer size you're doing unnecessary inspection to find and split on line terminators

[issue21234] __contains__ and friends should check is for all elements first

2014-04-15 Thread Wolfgang Maier
Wolfgang Maier added the comment: - if an object is in the container that is equal to the object, it will be slower, but not very much. You don't know that in general. It depends on where in the sequence the equal object sits, and also on how expensive the equality check is compared

[issue21234] __contains__ and friends should check is for all elements first

2014-04-16 Thread Wolfgang Maier
Wolfgang Maier added the comment: I don't even know where to start with this. a) this recipe is not working b) it's hardly readable c) it is pointless Why are you complicating things by testing for != ? What advantage does this offer over == ? You do not need class methods at all

[issue21234] __contains__ and friends should check is for all elements first

2014-04-16 Thread Wolfgang Maier
Wolfgang Maier added the comment: that clarifies things, thanks. I would still not usually go that way though as it means defining __ne__ with no accompanying __eq__, which means that, in a simple case, you can't use == on instances of your class and, in the case that your class inherits

[issue21234] __contains__ and friends should check is for all elements first

2014-04-16 Thread Wolfgang Maier
Wolfgang Maier added the comment: l=[myObj() for x in range(1)] now compare: 1 in m # slowed down by myObj.__eq__ False any(e is 1 for e in m) # identity checks only False oops, sorry for the inconsistency here. the first line should read: m = [myObj() for x in range(1

[issue21121] -Werror=declaration-after-statement is added even for extension modules through setup.py

2014-04-16 Thread Wolfgang Maier
Wolfgang Maier added the comment: I ran into this issue right after 3.4 got released. I solved it by adding extra_compile_args=[-Wno-error=declaration-after-statement] as an argument to the Extension() call in the package's setup.py . -- nosy: +wolma

[issue21533] built-in types dict docs - construct dict from iterable, not iterator

2014-05-19 Thread Wolfgang Maier
New submission from Wolfgang Maier: The docs for Python3.4 havethis to say about the arguments to the dict constructor: class dict(**kwarg) class dict(mapping, **kwarg) class dict(iterable, **kwarg) Return a new dictionary initialized from an optional positional argument and a possibly

[issue21560] gzip.write changes trailer ISIZE field before type checking - corrupted gz file after trying to write string

2014-05-23 Thread Wolfgang Maier
New submission from Wolfgang Maier: I ran into this: gzout = gzip.open('test.gz','wb') gzout.write('abcdefgh') # write expects bytes not str Traceback (most recent call last): File pyshell#2, line 1, in module gzout.write('abcdefgh') File /usr/lib/python3.4/gzip.py, line 343, in write

[issue21560] gzip.write changes trailer ISIZE field before type checking - corrupted gz file after trying to write string

2014-05-23 Thread Wolfgang Maier
Wolfgang Maier added the comment: ok, this seems to be really easy: patch attached -- keywords: +patch Added file: http://bugs.python.org/file35323/GzipFile_write.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21560

[issue21560] gzip.write changes trailer ISIZE field before type checking - corrupted gz file after trying to write string

2014-05-23 Thread Wolfgang Maier
Wolfgang Maier added the comment: or not - my patch just causes a different error in my example :( -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21560

[issue21560] gzip.write changes trailer ISIZE field before type checking - corrupted gz file after trying to write string

2014-05-23 Thread Wolfgang Maier
Wolfgang Maier added the comment: isn't this exactly what I did in my patch ? actually, it is working, I just had an error in my preliminary test script. I may be able to work on an official test at some point, but definitely not over the next week

[issue21993] counterintuitive behavior of list.index with boolean values

2014-07-16 Thread Wolfgang Maier
New submission from Wolfgang Maier: l = [False, True] l.index(True) 1 l.index(False) 0 good, but: l = ['a', '', {}, 2.7, 1, 0, False, True] l.index(True) 4 l.index(False) 5 Apparently, True and False get converted to int in comparisons to ints. I would expect items to be compared either

[issue21993] counterintuitive behavior of list.index with boolean values

2014-07-16 Thread Wolfgang Maier
Wolfgang Maier added the comment: No, it's not that simple and I don't think this should be closed: In my example: l = ['a', '', {}, 2.7, 1, 0, False, True] l.index(True) 4 l.index(False) 5 if using __eq__ consistently, you'd expect the first call to return 0 and the second 1 (since

[issue21993] counterintuitive behavior of list.index with boolean values

2014-07-16 Thread Wolfgang Maier
Wolfgang Maier added the comment: Right, forgot about that. The consequence for the example is still far from satisfying, I think, but you can't change it without breaking compatibility then. Thanks for the quick reply, Wolfgang -- ___ Python

[issue1152248] Add support for reading records with arbitrary separators to the standard IO stack

2014-07-20 Thread Wolfgang Maier
Changes by Wolfgang Maier wolfgang.ma...@biologie.uni-freiburg.de: -- nosy: +wolma ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1152248

[issue9882] abspath from directory

2014-07-24 Thread Wolfgang Maier
Changes by Wolfgang Maier wolfgang.ma...@biologie.uni-freiburg.de: -- nosy: +wolma ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9882

[issue22477] GCD in Fractions

2014-09-24 Thread Wolfgang Maier
Wolfgang Maier added the comment: Wouldn't it make more sense to change gcd() in the fractions module to return only positive integers? The current gcd could become _gcd for private use by fractions, and the new wrapper gcd could just be implemented as: def gcd(a,b): return abs(_gcd(a, b

[issue22486] Speed up fractions.gcd()

2014-09-25 Thread Wolfgang Maier
Changes by Wolfgang Maier wolfgang.ma...@biologie.uni-freiburg.de: -- nosy: +wolma ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22486

[issue1682] Move Demo/classes/Rat.py to Lib/fractions.py and fix it up.

2014-09-25 Thread Wolfgang Maier
Changes by Wolfgang Maier wolfgang.ma...@biologie.uni-freiburg.de: -- nosy: +wolma ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1682

[issue22495] merge large parts of test_binop.py and test_fractions.py

2014-09-25 Thread Wolfgang Maier
New submission from Wolfgang Maier: test_binop.py says that it tests binary operators on subtypes of built-in types, but in fact largely focuses on testing its own class Rat, which simply inherits from object and is, essentially, just a simple implementation of fractions.Fraction. Instead

[issue22486] Add math.gcd()

2014-09-25 Thread Wolfgang Maier
Wolfgang Maier added the comment: see issue22477 for a discussion of whether the behavior of fractions.gcd should be changed or not -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22486

[issue22486] Add math.gcd()

2014-09-25 Thread Wolfgang Maier
Wolfgang Maier added the comment: sorry, forgot to format the link: issue22477 -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22486

[issue22486] Add math.gcd()

2014-09-25 Thread Wolfgang Maier
Wolfgang Maier added the comment: I wasn't arguing for or against anything, just providing a link to the relevant discussion. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22486

[issue11874] argparse assertion failure with brackets in metavars

2014-10-28 Thread Wolfgang Maier
Wolfgang Maier added the comment: It doesn't seem to be the exact same problem, but still this very simple example with parentheses in metavar fails to format correctly: import argparse parser = argparse.ArgumentParser() parser.add_argument(inputfiles, metavar = 'input_file(s)', nargs

[issue23465] Implement PEP 486 - Make the Python Launcher aware of virtual environments

2015-02-20 Thread Wolfgang Maier
Wolfgang Maier added the comment: am I correct that when a script contains a shebang line like: #! python3 or #! python3.4 i.e., one indicating just a version of, but not a full path to the interpreter, the current patch would not use an active virtualenv even if it has a suitable version

[issue23688] unnecessary copying of memoryview in gzip.GzipFile.write?

2015-03-18 Thread Wolfgang Maier
Wolfgang Maier added the comment: Thanks everyone for the lively discussion ! I like Serhiy's idea of making write work with arbitrary objects supporting the buffer protocol. In fact, I noticed before that GzipFile.write misbehaves with array.array input. It pretends to accept

[issue23378] argparse.add_argument action parameter should allow value extend

2015-03-22 Thread Wolfgang Maier
Wolfgang Maier added the comment: - I haven't seen other requests for it For the record, an Extend custom action class is one of very few such classes I have ever written for argparse for exactly the OP's usecase, i.e., it is useful for any parser that should accept the same option multiple

[issue23700] tempfile.NamedTemporaryFile can close too early if used as iterator

2015-03-19 Thread Wolfgang Maier
Changes by Wolfgang Maier wolfgang.ma...@biologie.uni-freiburg.de: -- nosy: +wolma ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23700

[issue23700] tempfile.NamedTemporaryFile can close too early if used as iterator

2015-03-20 Thread Wolfgang Maier
Wolfgang Maier added the comment: I think this is a consequence of PEP380 and its decision to finalize the subgenerator when the delegating generator is closed. Consider this simple example without tempfile: def yielder (fileobj): yield from fileobj with open('some_test_file', 'w') as f

[issue23700] tempfile.NamedTemporaryFile can close too early if used as iterator

2015-03-20 Thread Wolfgang Maier
Wolfgang Maier added the comment: Actually, its scary that use of yield from can have such a subtle side-effect. Maybe PEP380 should have taken this more seriously? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23700

[issue23700] tempfile.NamedTemporaryFile can close too early if used as iterator

2015-03-20 Thread Wolfgang Maier
Wolfgang Maier added the comment: @Serhiy in this line of code: reader = csv.DictReader(fileobj, fieldnames=next(csv.reader(fileobj))) csv.reader(fileobj) returns the generator created by fileobj.__iter__, but no reference to it is kept so the object gets destroyed right afterwards

[issue23700] tempfile.NamedTemporaryFile can close too early if used as iterator

2015-03-20 Thread Wolfgang Maier
Wolfgang Maier added the comment: so let's look at this step-by-step (and I hope I fully understood this myself): - calling fileobj.__iter__ creates a generator because the method uses yield from - that generator does not get assigned to any reference so it will be garbage-collected - when

[issue23529] Limit decompressed data when reading from LZMAFile and BZ2File

2015-03-20 Thread Wolfgang Maier
Wolfgang Maier added the comment: The patch has a huge block replacement in the gzip.py module starting at GzipFile.write, which makes it large and hard to identify changes. Could that be ameliorated or is it too much work right now? -- nosy: +wolma

[issue23688] unnecessary copying of memoryview in gzip.GzipFile.write?

2015-03-20 Thread Wolfgang Maier
Wolfgang Maier added the comment: ok, I've prepared a patch including tests based on my last suggestion, which I think is ready for getting reviewed. -- Added file: http://bugs.python.org/file38600/write_bytes_like_objects.patch ___ Python tracker

[issue23700] tempfile.NamedTemporaryFile can close too early if used as iterator

2015-03-20 Thread Wolfgang Maier
Wolfgang Maier added the comment: OTOH, it would be very hard to change the way fileobjects compared to designing yield from differently so I'd still blame it partly. Maybe it is unfortunate that generators have a close method instead of, say, __close__

[issue23700] tempfile.NamedTemporaryFile can close too early if used as iterator

2015-03-20 Thread Wolfgang Maier
Wolfgang Maier added the comment: You are probably right that the io classes are broken. From https://docs.python.org/3/library/stdtypes.html#iterator-types: Once an iterator’s __next__() method raises StopIteration, it must continue to do so on subsequent calls. Implementations that do

[issue23700] tempfile.NamedTemporaryFile can close too early if used as iterator

2015-03-20 Thread Wolfgang Maier
Wolfgang Maier added the comment: @bkabrda not sure, but it may have to do with when exactly the object gets garbage collected -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23700

[issue23688] unnecessary copying of memoryview in gzip.GzipFile.write ?

2015-03-17 Thread Wolfgang Maier
New submission from Wolfgang Maier: I thought I'd go back to work on a test patch for issue21560 today, but now I'm puzzled by the explicit handling of memoryviews in gzip.GzipFile.write. The method is defined as: def write(self,data): self._check_closed() if self.mode

[issue23688] unnecessary copying of memoryview in gzip.GzipFile.write ?

2015-03-17 Thread Wolfgang Maier
Changes by Wolfgang Maier wolfgang.ma...@biologie.uni-freiburg.de: -- keywords: +patch Added file: http://bugs.python.org/file38521/memoryview_write.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23688

[issue23688] unnecessary copying of memoryview in gzip.GzipFile.write ?

2015-03-17 Thread Wolfgang Maier
Wolfgang Maier added the comment: Here is a patch with memoryview tests. Are tests and code patches supposed to go in one file or separate ones ? -- Added file: http://bugs.python.org/file38526/test_memoryview_write.patch ___ Python tracker rep

[issue23688] unnecessary copying of memoryview in gzip.GzipFile.write ?

2015-03-17 Thread Wolfgang Maier
Wolfgang Maier added the comment: memoryview is converted to bytes because len() for memoryview returns a size of first dimension (a number of items for one-dimension view), not a number of bytes. m = memoryview(array.array('I', [1, 2, 3])) len(m) 3 len(m.tobytes()) 12 len(m.cast('B

[issue23688] unnecessary copying of memoryview in gzip.GzipFile.write ?

2015-03-17 Thread Wolfgang Maier
Wolfgang Maier added the comment: @Serhiy: Why would data = data.cast('B') be required ? When would the memoryview not be in 'B' format already ? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23688

[issue23787] sum() function docstring lists arguments incorrectly

2015-03-28 Thread Wolfgang Maier
Wolfgang Maier added the comment: This implies sum() should accept str, unicode, list, tuple, bytearray, buffer, and xrange. and in fact it *does* accept all these as input. It just refuses to add the elements of the sequence if these elements are of certain types. Of course, the elements

[issue23602] Implement __format__ for Fraction

2015-03-29 Thread Wolfgang Maier
Wolfgang Maier added the comment: Initially, I also thought that this should be addressable with Fraction.__round__ or an optimized variation of it, but Tuomas is right that it gets complicated by the fact that you need to cope with the different format specifiers and not all of them fit

[issue23688] unnecessary copying of memoryview in gzip.GzipFile.write?

2015-03-22 Thread Wolfgang Maier
Wolfgang Maier added the comment: Here is a revised version of my patch addressing Serhiy's review comments. -- Added file: http://bugs.python.org/file38639/write_bytes_like_objects_v2.patch ___ Python tracker rep...@bugs.python.org http

[issue23688] unnecessary copying of memoryview in gzip.GzipFile.write?

2015-03-23 Thread Wolfgang Maier
Wolfgang Maier added the comment: I see now that it is just issue21560 that went into 2.7 and that's fine. As I said: sorry for the noise -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23688

[issue23688] unnecessary copying of memoryview in gzip.GzipFile.write?

2015-03-23 Thread Wolfgang Maier
Wolfgang Maier added the comment: to preserve compatibility: there is the memoryview.c_contiguous flag. Maybe we should just check it and if it is False fall back to the old copying behavior ? -- ___ Python tracker rep...@bugs.python.org http

[issue23688] unnecessary copying of memoryview in gzip.GzipFile.write?

2015-03-23 Thread Wolfgang Maier
Wolfgang Maier added the comment: something like: def write(self,data): self._check_closed() if self.mode != WRITE: import errno raise OSError(errno.EBADF, write() on read-only GzipFile object) if self.fileobj is None: raise

[issue23688] unnecessary copying of memoryview in gzip.GzipFile.write?

2015-03-23 Thread Wolfgang Maier
Wolfgang Maier added the comment: Serhiy: I think I saw that you committed this also to the 2.7 branch, but that would not work since memoryviews do not have the nbytes attribute (they do not seem to have cast either). One would have to calculate the length instead from other properties

[issue23688] unnecessary copying of memoryview in gzip.GzipFile.write?

2015-03-23 Thread Wolfgang Maier
Wolfgang Maier added the comment: ouch. haven't thought of this. OTOH, just plain io with your example: with open('xy', 'wb') as f: f.write(y) Traceback (most recent call last): File pyshell#29, line 2, in module f.write(y) BufferError: memoryview: underlying buffer is not C

[issue23465] Implement PEP 486 - Make the Python Launcher aware of virtual environments

2015-02-21 Thread Wolfgang Maier
Wolfgang Maier added the comment: So, with the current patch users could still not use the py launcher from a virtual environment with scripts that are supposed to work under UNIX :( Correct. That's not the problem this PEP is intended to solve. Granted :) Another PEP could be written

[issue23465] Implement PEP 486 - Make the Python Launcher aware of virtual environments

2015-02-20 Thread Wolfgang Maier
Wolfgang Maier added the comment: isn't the pyvenv.cfg file specifying the version ? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23465

[issue23465] Implement PEP 486 - Make the Python Launcher aware of virtual environments

2015-02-20 Thread Wolfgang Maier
Wolfgang Maier added the comment: Hmm, I didn't know that (although virtualenv-based environments don't have an equivalent to pyvenv.cfg). Well, that complicates things then :( But there's some confusion here. This patch only affects command line usage (running py.exe to start Python

[issue23602] Implement __format__ for Fraction

2015-03-26 Thread Wolfgang Maier
Wolfgang Maier added the comment: Decimal formatting intentionally differs from float formatting, see #23460. I see. Thanks for the pointer. What about the missing zero in the exponent ? -- ___ Python tracker rep...@bugs.python.org http

[issue23602] Implement __format__ for Fraction

2015-03-26 Thread Wolfgang Maier
Wolfgang Maier added the comment: actually, I'm not sure whether formatting Decimals gives correct output under all conditions (correctly rounded yes, but maybe not formatted correctly?). compare: format(float('1.481e-6'),'.3g') '1.48e-06' format(Decimal('1.481e-6'),'.3g') '0.0148

[issue23688] unnecessary copying of memoryview in gzip.GzipFile.write?

2015-03-23 Thread Wolfgang Maier
Changes by Wolfgang Maier wolfgang.ma...@biologie.uni-freiburg.de: Added file: http://bugs.python.org/file38650/write_bytes_like_objects_v3.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23688

[issue23933] Struct module should acept arrays

2015-04-13 Thread Wolfgang Maier
Changes by Wolfgang Maier wolfgang.ma...@biologie.uni-freiburg.de: -- nosy: -wolma ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23933

[issue23933] Struct module should acept arrays

2015-04-13 Thread Wolfgang Maier
Wolfgang Maier added the comment: I'm afraid you lost me and I do not see what your problem is here. Maybe you should raise this on one of the Python mailing lists (see https://www.python.org/community/lists/) ? -- ___ Python tracker rep

[issue23975] numbers.Rational implements __float__ incorrectly

2015-04-20 Thread Wolfgang Maier
Wolfgang Maier added the comment: Is it not reasonable to simply say that implementations of numbers.Rational which allow the numerator and denominator to have types for which true division doesn't return a float, have to provide their own implementation of __float__()? Unfortunately

[issue23975] numbers.Rational implements __float__ incorrectly

2015-04-20 Thread Wolfgang Maier
Wolfgang Maier added the comment: Good point. If the numbers ABC guaranteed numerator and denominator to be Integral numbers, this could be solved by: return float(int(self.numerator) / int(self.denominator)) but since both could be Rationals again that does not seem to be an option either

[issue22881] show median in benchmark results

2015-04-26 Thread Wolfgang Maier
Wolfgang Maier added the comment: for the even number case, I think you shouldn't do // 2, but / 2. In general, wouldn't it be good to let the statistics module do all the stats calculations? -- ___ Python tracker rep...@bugs.python.org http

[issue22881] show median in benchmark results

2015-04-26 Thread Wolfgang Maier
Wolfgang Maier added the comment: ah sorry, it's late here already and I forgot what file this change is about. So forget my last comment then. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22881

[issue22881] show median in benchmark results

2015-04-26 Thread Wolfgang Maier
Changes by Wolfgang Maier wolfgang.ma...@biologie.uni-freiburg.de: -- nosy: +wolma ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22881

[issue22881] show median in benchmark results

2015-04-26 Thread Wolfgang Maier
Wolfgang Maier added the comment: It's not available in older Python versions, e.g. 2.6. I know, I was talking about 3.5+, of course. This would not be backported to Python2 anyway, would it? -- ___ Python tracker rep...@bugs.python.org http

[issue23356] In argparse docs simplify example about argline

2015-04-24 Thread Wolfgang Maier
Changes by Wolfgang Maier wolfgang.ma...@biologie.uni-freiburg.de: -- nosy: +wolma ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23356

[issue8538] Add FlagAction to argparse

2015-04-29 Thread Wolfgang Maier
Changes by Wolfgang Maier wolfgang.ma...@biologie.uni-freiburg.de: -- nosy: +wolma ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8538

[issue23975] numbers.Rational implements __float__ incorrectly

2015-04-27 Thread Wolfgang Maier
Wolfgang Maier added the comment: After considering this for a while, I think: return float(self.numerator / self.denominator) is the best solution: * it is simple and works reasonably well as a default * it fixes Rational.__float__ for cases, in which numerator / denominator returns

[issue24068] statistics module - incorrect results with boolean input

2015-04-28 Thread Wolfgang Maier
Changes by Wolfgang Maier wolfgang.ma...@biologie.uni-freiburg.de: Removed file: http://bugs.python.org/file39220/statistics._sum.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24068

[issue24068] statistics module - incorrect results with boolean input

2015-04-28 Thread Wolfgang Maier
Changes by Wolfgang Maier wolfgang.ma...@biologie.uni-freiburg.de: Added file: http://bugs.python.org/file39221/statistics._sum.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24068

[issue24068] statistics module - incorrect results with boolean input

2015-04-28 Thread Wolfgang Maier
New submission from Wolfgang Maier: the mean function in the statistics module gives nonsensical results with boolean values in the input, e.g.: mean([True, True, False, False]) 0.25 mean([True, 1027]) 0.5 This is an issue with the module's internal _sum function that mean relies

[issue24068] statistics module - incorrect results with boolean input

2015-05-02 Thread Wolfgang Maier
Wolfgang Maier added the comment: uploading an alternate, possibly slightly clearer version of the patch -- Added file: http://bugs.python.org/file39269/statistics._sum.v2.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org

[issue5680] Command-line arguments when running in IDLE

2015-04-16 Thread Wolfgang Maier
Changes by Wolfgang Maier wolfgang.ma...@biologie.uni-freiburg.de: -- nosy: +wolma ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5680

[issue23975] numbers.Rational implements __float__ incorrectly

2015-04-16 Thread Wolfgang Maier
New submission from Wolfgang Maier: numbers.Rational defines __float__ like this: def __float__(self): float(self) = self.numerator / self.denominator It's important that this conversion use the integer's true division rather than casting one side to float before dividing so

  1   2   3   >