Re: A use-case for for...else with no break

2017-11-02 Thread Paul Rubin
Steve D'Aprano writes: > for x in something(): > print(x, end='') print(''.join(something())) -- https://mail.python.org/mailman/listinfo/python-list

Re: Let's talk about debuggers!

2017-10-26 Thread Paul Rubin
Terry Reedy writes: > On Windows, [IDLE] uses native widgets when possible... > In summary, I think debugger should rate at least 'good' rather than > fail' when it comes to showing you the next line. I actually like how the Tk widgets look. I've done some semi-industrial applications with tkint

Re: I'd like to use "semantic indentation"

2017-09-30 Thread Paul Rubin
Chris Angelico writes: > USA: > Alabama: > Abbeville > Addison > ... > and then, as Paul suggested, write a simple parser to read it. That looks like YAML, which there's already a library for. I'm not crazy about it but it might be an ok choice for this. -- https://m

Re: I'd like to use "semantic indentation"

2017-09-30 Thread Paul Rubin
r...@zedat.fu-berlin.de (Stefan Ram) writes: > I would like to write source code similar to: > country( 'USA' ) > state( 'Alabama' ) Aside from the workaround that I mentioned, this looks more like data than code. Maybe you really want to create a nested structure (dictionaries, JSON, XML or

Re: I'd like to use "semantic indentation"

2017-09-30 Thread Paul Rubin
r...@zedat.fu-berlin.de (Stefan Ram) writes: > I would like to write source code similar to: > country( 'USA' ) > state( 'Alabama' ) ... > It seems I can't do this with Python. Is there any workaround? _= country( 'USA' ) _= state( 'Alabama' ) _= town( 'Abbeville' ) _= town

Re: Project Euler 20.

2017-09-24 Thread Paul Rubin
Ian Kelly writes: sum(int(c) for c in str(math.factorial(100))) Doh! Using int(c) didn't occur to me and I didn't know about math.factorial. Notice also that WJ hasn't yet dared posting his crap on comp.lang.haskell. -- https://mail.python.org/mailman/listinfo/python-list

Re: Project Euler 20.

2017-09-24 Thread Paul Rubin
"Robert L." writes: >> Find the sum of the digits in the number 100! > In Python? So you have come to plague us here too. >>> sum(ord(c)-ord('0') for c in str(reduce(lambda a,b: a*b, range(1,101),1))) 648 -- https://mail.python.org/mailman/listinfo/python-list

Re: Old Man Yells At Cloud

2017-09-21 Thread Paul Rubin
Steve D'Aprano writes: > Having to spend a few hours being paid to migrate code using "print x" > to "print(x)", or even a few months, is not a life-changing experience. Didn't someone further up the thread mention some company that had spent 1.5 years porting a py2 codebase to py3? The issue of

Re: [RELEASE] Python 3.6.3rc1 and 3.7.0a1 are now available for testing and more

2017-09-19 Thread Paul Rubin
Ned Deily writes: > You can find Python 3.7.0a1 and more information here: > https://www.python.org/downloads/release/python-370a1/ This says: The next pre-release of Python 3.7 will be 3.6.0a2, currently scheduled for 2016-10-16. :) -- https://mail.python.org/mailman/listinfo/pyth

Re: Old Man Yells At Cloud

2017-09-16 Thread Paul Rubin
Steve D'Aprano writes: >> concept integer / integer => integer_result > That would be C, and C derived languages, perhaps? Certainly not. Fortran, machine languages, etc. all do that too. Haskell does the right thing and makes int/int a compile time type error. Its integer divisi

Re: The Incredible Growth of Python (stackoverflow.blog)

2017-09-13 Thread Paul Rubin
Ben Finney writes: >> I've never seen one. > who has told you... they are working on a Python 3 code base. Just because they've told me about it doesn't mean I saw it personally. The ones I've seen, including new ones, are Python 2. Some people here use Py3 but I haven't heard (or don't remember

Re: The Incredible Growth of Python (stackoverflow.blog)

2017-09-12 Thread Paul Rubin
Chris Angelico writes: > Why? Unless they're going to be maintaining a Py2 codebase, why should > they learn the older version with less features? Are there actually Py3 codebases? I guess there must be, even though I've never seen one. Every Python codebase of any size that I know of is Py2.

Re: Using Python 2

2017-09-11 Thread Paul Rubin
Steve D'Aprano writes: > Guido has ruled that Python 4 will not be a major compatibility break Looking forward to Python 5 then ;-). -- https://mail.python.org/mailman/listinfo/python-list

Re: The Incredible Growth of Python (stackoverflow.blog)

2017-09-11 Thread Paul Rubin
Chris Angelico writes: > students learning Python *today* ... they're learning Python 3. I'm not so sure of that. I do know a few people currently learning Python, and they're using Python 2. >> * static type annotation Seems like a big win if you ask me. >> * asyncio with its a-dialect > A

Re: How do I find what kind of exception is thrown.

2017-09-05 Thread Paul Rubin
Antoon Pardon writes: > Now I found the following in the logs: [Errno 131] Connection reset by peer > This is a problem I would like to catch earlier I'd expect that's an IOError thrown by the socket library. You could just let it go uncaught and see what you get in the crash dump. -- https://

Re: BeautifulSoup doesn't work with a threaded input queue?

2017-08-27 Thread Paul Rubin
Christopher Reimer writes: > I have 20 read_threads requesting and putting pages into the output > queue that is the input_queue for the parser. Given how slow parsing is, you probably want to scrap the pages into disk files, and then run the parser in parallel processes that read from the disk.

Re: Reading the documentation

2017-08-24 Thread Paul Rubin
Chris Angelico writes: >> And there are numbers which repeat in decimal but not binary, > Which ones repeat in decimal but not binary? An example, please. That should really have said binary but not decimal, since 2 divides 10. -- https://mail.python.org/mailman/listinfo/python-list

Re: Proposed new syntax

2017-08-24 Thread Paul Rubin
Steve D'Aprano writes: > Did __next__ cache the most recently generated value? No but if they're going to change stuff, they might as well actually improve it instead of just renaming it to break code gratutiously. -- https://mail.python.org/mailman/listinfo/python-list

Re: Proposed new syntax

2017-08-24 Thread Paul Rubin
Steve D'Aprano writes: > the public API is to call the next() built-in function, and the > implementation is the __next__ dunder. In that case it would have been nice to make next() cache the most recently generated value from the iterator. That would make lots of code simpler. -- https://mail.

Re: Proposed new syntax

2017-08-24 Thread Paul Rubin
Peter Otten <__pete...@web.de> writes: > Python 3 where the next() method has been renamed to __next__(). Oh cripes, you're right, it never occurred to me that py3 had broken .next(). I thought it was called .next() instead of .__next() so that it wouldn't be a dunder method. -- https://mail.pyt

Re: Proposed new syntax

2017-08-24 Thread Paul Rubin
Steve D'Aprano writes: > I've read a few people claim that disallowing multiplication from > standard arithmetic renders it weak enough that you can prove it > complete and correct, but since they give no proof or even evidence I > have my doubts. That system is called Presburger arithmetic (see

Re: Proposed new syntax

2017-08-24 Thread Paul Rubin
Ben Finney writes: > generate_id = functools.partial(next, itertools.count()) Is something wrong with: >>> g = itertools.count().next >>> g() 0 >>> g() 1 >>> g() 2 >>> ... -- https://mail.python.org/mailman/listinfo/python-list

Re: Proposed new syntax

2017-08-21 Thread Paul Rubin
Rustom Mody writes: > Do you mean Frege or Cantor? Frege. Cantor was concerned with set theory, while Frege was concerned with logic in general. Frege's notation was different from what we use now but the issue was about the same: unrestricted comprehension led to contradiction. As you mention

Re: Proposed new syntax

2017-08-19 Thread Paul Rubin
Rustom Mody writes: > Specifically the term 'comprehension' used today as a programming construct > traces somewhat tenuously to an axiom that Zermelo/Fraenkel formulated > in the 1920s I thought went back to Frege. Also, it appears in Zermelo set theory Z. ZF is Z with the Axiom of Replacement

Re: Proposed new syntax

2017-08-18 Thread Paul Rubin
Marko Rauhamaa writes: > The question is, is it bad style—or even an error—to rely on the > execution order of the comprehension loops? Bad style: IMO, yes, most of the time. I've made use of it at particular times. If it's done in an obscure way it at least deserves a code commment. Error: n

Re: What extended ASCII character set uses 0x9D?

2017-08-17 Thread Paul Rubin
John Nagle writes: > Since, as someone pointed out, there was UTF-8 which had been > run through an ASCII-type lower casing algorithm I spent a few minutes figuring out if some of the mysterious 0x81's could be from ASCII-lower-casing some Unicode combining characters, but the numbers didn't seem

Re: Proposed new syntax

2017-08-17 Thread Paul Rubin
Steve D'Aprano writes: > For loops and comprehensions (in Python) are inherently procedural, Sure, and floating point arithmetic is inherently imprecise and doesn't follow the associative laws for either addition or multiplication. There are times when we have to be aware of those details. Usual

Re: Cross-language comparison: function map and similar

2017-08-16 Thread Paul Rubin
Steve D'Aprano writes: > Are there language implementations which evaluate the result of map() > (or its equivalent) in some order other than the obvious left-to-right > first-to-last sequential order? Is that order guaranteed by the > language, or is it an implementation detail? Haskell just giv

Re: Proposed new syntax

2017-08-14 Thread Paul Rubin
Paul Rubin writes: > FORALL P. [ P(0) and P(n) -> P(n+1) ] Sorry, that was supposed to say FORALL P. [ (P(0) and P(n) -> P(n+1)) -> forall n. P(n) ] FORALL quantifies over formulas and forall quantifies over numbers. Maybe something is still missing from the above ;-

Re: Proposed new syntax

2017-08-14 Thread Paul Rubin
Marko Rauhamaa writes: > For the non-logicians in the audience, an "axiom schema" is a generator > pattern that produces an infinity of actual axioms. For non-logicians this is not worth worrying about: schemas are basically a technical hack to get around the inability of first-order logic to qu

Re: Proposed new syntax

2017-08-14 Thread Paul Rubin
Steve D'Aprano writes: > It's quite clever, actually, in that it gives *pseudo* random-access > with lazy evaluation. You can evaluate the Nth element without > evaluating the earlier ones. But you can't do so without *storing* the > previous ones, they have to be allocated, with only the actual >

Re: Proposed new syntax

2017-08-14 Thread Paul Rubin
Steve D'Aprano writes: > And very possibly the first language with comprehensions, SETL (from 1969), > used "forall" ... It goes back much further, probably to Principia Mathematica, or (with different notation) maybe Frege's Foundations of Arithmetic: https://en.wikipedia.org/wiki/Set-builde

Re: Proposed new syntax

2017-08-14 Thread Paul Rubin
Marko Rauhamaa writes: > Jussi Piitulainen : >> But what is "set comprehension" in French, German, or Finnish? The idea comes from set theory: for some reason English Wikipedia doesn't have Finnish cross-wiki links for most of the relevant terms, but Google translates "axiom of specification" as

Re: Proposed new syntax

2017-08-11 Thread Paul Rubin
Steve D'Aprano writes: > What would you expect this syntax to return? > [x + 1 for x in (0, 1, 2, 999, 3, 4) while x < 5] [1,2,3] though the later example is more confusing. I don't think we need this since we have itertools.takewhile: from operator import gt from functools import partial

Re: Challenge: find the first value where two functions differ

2017-08-05 Thread Paul Rubin
Chris Angelico writes: > 4503599761588224 I get the same result from searching a wider interval (+/- 50) around each perfect square in the relevant range. -- https://mail.python.org/mailman/listinfo/python-list

Re: YAML in std lib?

2017-07-31 Thread Paul Rubin
Ben Finney writes: > I don't know of any PEP yet which specifies exactly what to add to the > standard library for YAML YAML is more of a Ruby thing, so there might not be much constituency for putting it in Python. -- https://mail.python.org/mailman/listinfo/python-list

Re: Falsey Enums

2017-07-28 Thread Paul Rubin
Dan Sommers writes: > def __bool__(self): > return False if self == X.Falsey else True return self != X.Falsey -- https://mail.python.org/mailman/listinfo/python-list

Re: OT was Re: Python 3 removes name binding from outer scope

2017-07-26 Thread Paul Rubin
Chris Angelico writes: >>> Bipartisan-US-Bill-Moves-to-Criminalize-BDS-Support-20170720-0001.html >> Heh, at first I read that as a bill to criminalise BSD support :-) > I spluttered my drink on reading that. Good job Steven! https://en.wikipedia.org/wiki/BDS_C -- https://mail.python.org/mailman

Re: Python 3 removes name binding from outer scope

2017-07-24 Thread Paul Rubin
Ben Finney writes: > How can I stop Python from deleting a name binding, when that name is > used for binding the exception that is caught? Use sys.exc_info() -- https://mail.python.org/mailman/listinfo/python-list

Re: Recent Spam problem

2017-07-24 Thread Paul Rubin
Rustom Mody writes: > Since spammers are unlikely to be choosy about whom they spam: > Tentative conclusion: Something about the USENET-ML gateway is more leaky > out here than elsewhere It could be a sort-of DOS attack by some disgruntled idiot. I wonder if the email address in those spam posts

Re: Write this accumuator in a functional style

2017-07-14 Thread Paul Rubin
Rustom Mody writes: > Yeah I know append method is supposedly O(1). It's amortized O(1). -- https://mail.python.org/mailman/listinfo/python-list

Re: Write this accumuator in a functional style

2017-07-13 Thread Paul Rubin
Chris Angelico writes: > Maybe I'm completely on the wrong track here, but the last time I > implemented a self-balancing tree, it usually involved a fair amount > of mutation. AVL trees are fairly simple to implement without mutation. Red-black trees are traditionally implemented with mutation,

Re: Write this accumuator in a functional style

2017-07-13 Thread Paul Rubin
Chris Angelico writes: > some point it'll need to be rebalanced, which could at worst case > be O(n). No, you use a structure like an AVL tree or red-black tree, so it's within a constant factor of balanced after each insertion. You rewrite O(log n) of the nodes, and juggle around a constant nu

Re: Write this accumuator in a functional style

2017-07-12 Thread Paul Rubin
Steven D'Aprano writes: > for parrot in parrots: > accumulator[parrot.colour].append(parrot) > > That's pretty compact and understandable, but it require mutating a bunch > of pre-allocated lists inside an accumulator. Can we re-write this in a > functional style? Not so easily in Python si

Re: What's with all of the Case Solution and Test Bank nonsense posts?

2017-07-10 Thread Paul Rubin
Michael Torrie writes: >> can you get a newsreader to work with a https news service? > No. A newsreader works with NNTP protocol. Traditionally NNTP over SSL was done on port 563. Some feeds now also provide it on 443 to get around client-side firewall hassles. -- https://mail.python.org/mail

Re: What's with all of the Case Solution and Test Bank nonsense posts?

2017-07-09 Thread Paul Rubin
timetowal...@gmail.com writes: > What's with all of the Case Solution and Test Bank nonsense posts? > Is is possible to have these posts filtered out? As people have said, you can block them with a good news reader. But like you, I wonder why the heck they have camped out on this particular newsg

Re: Checking for an exception

2017-06-25 Thread Paul Rubin
Steve D'Aprano writes: > What's the right/best way to test whether an object is an exception > ahead of time? (That is, without trying to raise from it.) Maybe I'm missing something but isinstance(obj, Exception) seems to work. -- https://mail.python.org/mailman/listinfo/python-list

Re: Progress on the Gilectomy (Posting On Python-List Prohibited)

2017-06-21 Thread Paul Rubin
Lawrence D’Oliveiro writes: > while “memory footprint” depends on how much memory is actually being > retained in accessible objects. If the object won't be re-accessed but is still retained by gc, then refcounting won't free it either. > Once again: The trouble with GC is, it doesn’t know when

Re: Progress on the Gilectomy

2017-06-21 Thread Paul Rubin
Lawrence D’Oliveiro writes: > The trouble with GC is, it doesn’t know when to kick in: it just keeps > on allocating memory until it runs out. That's not how GC works, geez. Typically it would run after every N bytes of memory allocated, for N chosen to balance memory footprint with cpu overhead

Re: Static typing [was Re: Python and the need for speed]

2017-06-21 Thread Paul Rubin
Gregory Ewing writes: > A JIT compiler works by observing the actual values To be pedantic, that's called a "tracing JIT". Other runtime code generation is also frequently called JIT compilation even when it's fairly stupid combining of assembly code templates, or the like. -- https://mail.pyth

Re: Looping [was Re: Python and the need for speed]

2017-06-21 Thread Paul Rubin
Chris Angelico writes: > while True: > c = sys.stdin.read(1) > if not c: break > if c.isprintable(): text += c > elif c == "\x08": text = text[:-1] > # etc > Can you write _that_ as a do-while? I prefer to write that sort of thing with iterators: for c in iter(lambda: sys.st

Re: Progress on the Gilectomy

2017-06-20 Thread Paul Rubin
Cem Karan writes: > I'm not too sure how much of performance impact that will have. My > code generates a very large number of tiny, short-lived objects at a > fairly high rate of speed throughout its lifetime. At least in the > last iteration of the code, garbage collection consumed less than 1

Re: Instagram: 40% Py3 to 99% Py3 in 10 months (Posting On Python-List Prohibited)

2017-06-20 Thread Paul Rubin
Steven D'Aprano writes: > genuinely good reason... (Which might include "the customer insists", > or "yeah, I know it sucks, but politics".) I think the current LTS versions of Ubuntu and Debian both come with Python 2. Not sure about Centos/RHEL. Those seem like ok reasons to me. > if you wa

Re: Progress on the Gilectomy

2017-06-19 Thread Paul Rubin
Cem Karan writes: > Can you give examples of how it's not reliable? Basically there's a chance of it leaking memory by mistaking a data word for a pointer. This is unlikely to happen by accident and usually inconsequential if it does happen, but maybe there could be malicious data that makes it

Re: Progress on the Gilectomy

2017-06-19 Thread Paul Rubin
Chris Angelico writes: > Or let's look at it a different way. Instead of using a PyObject* in C > code, you could write C++ code that uses a trivial wrapper class that > holds the pointer, increments its refcount on construction, and > decrements that refcount on destruction. That's the C++ STL s

Re: Instagram: 40% Py3 to 99% Py3 in 10 months (Posting On Python-List Prohibited)

2017-06-19 Thread Paul Rubin
Lawrence D’Oliveiro writes: > Is Python 2 the Windows XP of the programming world? That's a good way to put it. It's nice to hear about Instagram but so far I don't personally know anyone who uses Python 3. Meanwhile there's still lots of new Py2 projects being started. -- https://mail.python.

Re: Instagram: 40% Py3 to 99% Py3 in 10 months

2017-06-18 Thread Paul Rubin
Paul Barry writes: > The process they followed is discussed in their recent Keynote at PyCon > 2017: https://youtu.be/66XoCk79kjM > Well worth the 40 minutes it takes to watch :-) If it takes 40 minutes to describe how they did it, that sounds like more hassle than most users of working py2 code

Re: Progress on the Gilectomy

2017-06-18 Thread Paul Rubin
I always thought the GIL removal obstacle was the need to put locks around every refcount adjustment, and the only real cure for that is to use a tracing GC. That is a good idea in many ways, but it would break the existing C API quite seriously. Reworking the C modules in the stdlib would be a l

Re: New to Python - Career question

2017-06-10 Thread Paul Rubin
Larry Martell writes: > I can tell they think I am old and they dismiss me right away. http://oldgeekjobs.com ? -- https://mail.python.org/mailman/listinfo/python-list

Re: [OT] How to improve my programming skills?

2017-06-03 Thread Paul Rubin
Mirko writes: > TLDR: Sorry for OT. Long-time Linux geek and hobby programmer wants to > improve his coding skills. What's most important: project planing, > algorithms and data structures, contributing to FOSS, web development, > learning other languages or something else? If it's specifically

Re: noCaptcha cracking handler

2017-06-03 Thread Paul Rubin
skyteacherus...@gmail.com writes: > Please check out my latest repository > https://github.com/gubrul/noCaptcha Thanks. Captchas have gotten to be a real PITA lately, even as someone who doesn't want to run automated clients on the infected sites. I remember getting sick of trying to identify pi

Re: Python package to accept payments in Internet

2017-05-09 Thread Paul Rubin
Chris Warrick writes: > there might be other users that will avoid your package for licensing > reasons. And there also might be other users who embrace the package for those same reasons. -- https://mail.python.org/mailman/listinfo/python-list

Re: Looping [was Re: Python and the need for speed]

2017-04-17 Thread Paul Rubin
Ben Bacarisse writes: > ? I get "AttributeError: 'itertools.dropwhile' object has no attribute > 'next'" from your example. Hmm, .next() worked ok for me in Python 2.7.5. Not sure what happened. Maybe something went wrong with my paste. Oh well. > Coming from the lazy language Haskell, I find

Re: Looping [was Re: Python and the need for speed]

2017-04-17 Thread Paul Rubin
Ben Bacarisse writes: > c = sys.stdin.read(1) > while c == ' ': > c = sys.stdin.read(1) c = itertools.dropwhile( lambda c: c==' ', iter(lambda: sys.stdin.read(1),None) ).next() -- https://mail.python.org/mailman/listinfo/python-list

Re: GPUs with various tools

2017-04-17 Thread Paul Rubin
Jeffrey Layton writes: > I'm working with Continuum's Accelerate and I'm slowly learning PyCUDA > but I'm looking for something that's already coded. TensorFlow has good Python bindings. That's probably the best way to get started. -- https://mail.python.org/mailman/listinfo/python-list

Re: Static typing [was Re: Python and the need for speed]

2017-04-17 Thread Paul Rubin
Steve D'Aprano writes: > On the other hand, there's Cython. Cython claims *not* to be a JIT compiler, One of the uses of "JIT compiler" these days is what's sometimes called a tracing JIT, like PyPy or LuaJIT or the Javascript flavor-of-the-week. That means it interprets the program while collect

Re: Bigotry and hate speech on the python mailing list

2017-04-17 Thread Paul Rubin
Rurpy writes: > A couple weeks ago a frequent poster here (Steve D'Aprano > ) called another participant an "ugly > american" Oh stop trolling. Ugly American was a 1950s thing, now just amusing. And context matters. Steven, please try to be a little more attentive to people's delicate feefees i

Re: Static typing [was Re: Python and the need for speed]

2017-04-16 Thread Paul Rubin
Steve D'Aprano writes: > Since it is *optional*, it is only a hint, not a fact. You can tell the > compiler that you believe that n will be an int, but it's not guaranteed. The runtime could check at the entry to the function that n is an int, and then it wouldn't have to keep re-checking on the

Re: Python and the need for speed

2017-04-14 Thread Paul Rubin
bartc writes: > I do know that if I want to port some program (be it in Python or > C++), or simply try and understand it, if I see it's full of class > definitions or whatever, then I won't bother. There was a time in the evolution of OOP when inheritance was thought of as a cool and enabling th

Re: Merging multiple sorted sequences.

2017-04-12 Thread Paul Rubin
Erik writes: > I need to be able to lazily merge a variable number of > already-sorted(*) variable-length sequences If the number of sequences is large, the traditional way is with the heapq module. -- https://mail.python.org/mailman/listinfo/python-list

Re: Python and the need for speed

2017-04-12 Thread Paul Rubin
Michael Torrie writes: > Equivalent to the JNI and Lisp FFI is the CFFI [1]. The JNI, the FFI, > and the CFFI, are all for calling native code from within their > respective languages, if I understand correctly. They don't define a > standard way for native code to call into these languages. Th

Re: Python and the need for speed

2017-04-12 Thread Paul Rubin
Marko Rauhamaa writes: > Traditionally, disk access in Linux has been considered nonblocking. > There is AIO, but that hasn't been used much. AIO is asynchronous but it's for dealing with already-opened files. There doesn't seem to be a way to asynchronously OPEN a file. > I believe the lack of

Re: Python and the need for speed

2017-04-12 Thread Paul Rubin
Brecht Machiels writes: > However, rinohtype is located in a very different niche and it would > greatly benefit a lot from a speed boost. Rendering the Sphinx > documentation (311 pages) takes almost 10 minutes on my i7 Yikes... > As for moving to a compiled language (Nim or Rust would be inter

Re: Python and the need for speed

2017-04-11 Thread Paul Rubin
Chris Angelico writes: > It's also entirely possible to have a single "application thread" and > then a "file opening thread" that does nothing but open files; Thanks. I think GHC and Erlang BEAM both do that. I hoped there was a better way. Note you potentially need multiple file opening thre

Re: Python and the need for speed

2017-04-11 Thread Paul Rubin
Chris Angelico writes: > Python, meanwhile, has made it easy to write blocking > I/O in a single-threaded program, and then adds async'ness to it. I'd be interested to know how to open a disk file asynchronously in a single-threaded Python program under Linux. As far as I can tell there is no wa

Re: Python and the need for speed

2017-04-11 Thread Paul Rubin
Mikhail V writes: > Just my curiosity, I've always been intersted in such question: are devs > still writing extensions in C, I mean type in C code? Yes. > Aren't they using some translator or IDE which at lest hides the > brackets and semicolons? I don't know of anyone who does that. I don't

Re: Python and the need for speed

2017-04-11 Thread Paul Rubin
Grant Edwards writes: > If there are now other Python implementations (e.g. MicroPython) with > C APIs that differ from CPython, then it seems like it is no longer > redundant to say "the CPython API". Perhaps there should be an attempt to define a unified API like the Java JNI, Lisp FFI's, etc.

Re: Python and the need for speed

2017-04-11 Thread Paul Rubin
Chris Angelico writes: > Do you mean this? > https://docs.python.org/3/c-api/intro.html Correct, smart guy ;-) -- https://mail.python.org/mailman/listinfo/python-list

Re: Python and the need for speed

2017-04-11 Thread Paul Rubin
Grant Edwards writes: > I didn't know there was such a thing as "The Python C API". It's described in this document: https://infohost.nmt.edu/tcc/help/lang/python/2_6_3/c-api.pdf You can tell that the document is about the Python/C API (ok, with a slash) because it says so at the top of the tit

Re: Python and the need for speed

2017-04-11 Thread Paul Rubin
Steven D'Aprano writes: > If we're going to talk about speeding up Python, we ought to talk about > *serious* approaches to the problem, not the musing of random, ignorant > bloggers and other naive commentators. So let's look at what the experts > have done: [list snipped] You might look

Re: Elastic Search

2017-04-08 Thread Paul Rubin
Steve D'Aprano writes: > What's elastic search? > And what does this have to do with Python? https://www.elastic.co/ (formerly elasticsearch.org). It's a Lucene-based distributed search engine, something like Solr if you're used to that. It has Python client libraries. That's the closest Pyth

Re: SimpleHTTPServer and CgiHTTPServer in practice

2017-03-16 Thread Paul Rubin
Lutz Horn writes: > We don't know *why* those people told you not to use these modules. We > also don't know your use case. So it is very hard to advise you. The use case is to have a very easily set up way to serve basic pages and files, without a lot of configuration files and other infrastruct

SimpleHTTPServer and CgiHTTPServer in practice

2017-03-15 Thread Paul Rubin
Sometimes I have a short term requirement to serve some data by http, so I've been using those modules rather than setting up a full featured web server. Some Python users have told me that isn't a good idea, but without any specifics. Are there any known problems with them such as security bugs,

Re: How to iterate through the columns in a row using sqlite3.Row

2017-03-12 Thread Paul Rubin
Chris Green writes: > self.conn = sqlite3.connect(dbname) > self.conn.row_factory = sqlite3.Row > self.cursor = self.conn.cursor() > self.table = table > ... > ... > sql = "SELECT * FROM " + self.table + " WHERE firstName||lastName = ?" >

Re: keyrings.cryptfile released on github

2017-03-10 Thread Paul Rubin
Hans-Peter Jansen writes: > [1] http://web.cs.ucdavis.edu/~rogaway/ocb/license.htm Oh that's interesting, he's expanded the free licenses. Still though, while OCB is very clever and it was important as the first satisfactory AEAD mode, I don't think it's that important these days. GCM is standa

Re: keyrings.cryptfile released on github

2017-03-09 Thread Paul Rubin
Hans-Peter Jansen writes: > I've released a keyring companion package today: > https://github.com/frispete/keyrings.cryptfile Interesting, I'll take a look at it. I wrote something like it many years ago but never did much with it. Thanks for posting! -- https://mail.python.org/mailman/l

Re: Who still supports recent Python on shared hosting

2017-03-05 Thread Paul Rubin
John Nagle writes: > I'm looking for shared hosting that supports at least Python 3.4. Open a ticket on buyshared.net and ask if they can install it for you. They're good about stuff like that. If it's for a cgi, you might alternatively be able to run it from your own directory (you get ssh acce

Re: Create ordering of points

2017-02-15 Thread Paul Rubin
spiess.benja...@googlemail.com writes: > Does somebody know a good technique for this problem? or can even give > a hint to a existing python procedure? You're asking about nearest neighbor search, which is the topic of a huge literature: https://en.wikipedia.org/wiki/Nearest_neighbor_search --

Re: WANT: bad code in python (for refactoring example)

2017-02-15 Thread Paul Rubin
Antoon Pardon writes: > On reason to use this is for some easy "logging" I think it's better to use the actual logging module. I generally start a new program with print statements but convert them to logging after there's enough code to want to be more organized about it. -- https://mail.pytho

Re: PEP 393 vs UTF-8 Everywhere

2017-01-21 Thread Paul Rubin
Chris Angelico writes: > You can't do a look-ahead with a vanilla string iterator. That's > necessary for a lot of parsers. For JSON? For other parsers you usually have a tokenizer that reads characters with maybe 1 char of lookahead. > Yes, which gives a two-level indexing (first find the stra

Re: PEP 393 vs UTF-8 Everywhere

2017-01-20 Thread Paul Rubin
Chris Angelico writes: > decoding JSON... the scanner, which steps through the string and > does the actual parsing. ... > The only way for it to be fast enough would be to have some sort of > retainable string iterator, which means exposing an opaque "position > marker" that serves no purpose oth

Re: Enum with only a single member

2017-01-10 Thread Paul Rubin
Steven D'Aprano writes: > Is it silly to create an enumeration with only a single member? No. > That is, a singleton enum? Why stop there? You can make empty ones too. (Zerotons?) > The reason I ask is that I have two functions that take an enum > argument. Sounds like a good reason. >

Re: Temporary variables in list comprehensions

2017-01-09 Thread Paul Rubin
Ben Bacarisse writes: > [(lambda tmp: (tmp, tmp+1))(expensive_calculation(x)) for x in data] Nice. The Haskell "let" expression is implemented as syntax sugar for that, I believe. -- https://mail.python.org/mailman/listinfo/python-list

Re: Temporary variables in list comprehensions

2017-01-09 Thread Paul Rubin
Tim Chase writes: >> result = [(tmp, tmp+1) for tmp in map(expensive_calculation, data)] > > As charmingly expressive as map() is, the wildly different behavior in > py3 (it's a generator that evaluates lazily) vs py2 (it consumes the > entire iterable in one go) leads me to avoid it in general,

Re: Temporary variables in list comprehensions

2017-01-09 Thread Paul Rubin
Serhiy Storchaka writes: > gen = (expensive_calculation(x) for x in data) > result = [(tmp, tmp + 1) for tmp in gen] result = [(tmp, tmp+1) for tmp in map(expensive_calculation, data)] -- https://mail.python.org/mailman/listinfo/python-list

Re: Temporary variables in list comprehensions

2017-01-09 Thread Paul Rubin
Steven D'Aprano writes: > [(expensive_calculation(x), expensive_calculation(x) + 1) for x in data] def memoize(f): cache = {} def m(x): if x in cache: return cache[x] a = f(x) cache[x] = a r

Re: Search a sequence for its minimum and stop as soon as the lowest possible value is found

2017-01-08 Thread Paul Rubin
Jussi Piitulainen writes: > It could still be added as an option, to both takewhile and iter(_, _). That's too messy, it really should be pervasive in iterators. -- https://mail.python.org/mailman/listinfo/python-list

Re: Search a sequence for its minimum and stop as soon as the lowest possible value is found

2017-01-08 Thread Paul Rubin
Peter Otten <__pete...@web.de> writes: > return min(take_until(), key=firstitem)[1] Actually, key=abs should work. I realized that after posting. -- https://mail.python.org/mailman/listinfo/python-list

Re: Search a sequence for its minimum and stop as soon as the lowest possible value is found

2017-01-08 Thread Paul Rubin
Paul Rubin writes: > seems to work, but is ugly. Maybe there's something better. def minabs2(xs): def z(): for x in xs: yield abs(x), x if x==0: break return min(z())[1] is the same thing but a little bit nicer. -

Re: Search a sequence for its minimum and stop as soon as the lowest possible value is found

2017-01-08 Thread Paul Rubin
Paul Rubin writes: > Doesn't look that way to me: > >>> minabs([5,3,1,2,4]) > 1 There's a different problem though: >>> minabs([1,2,3,0]) 1 I think Python's version of iterators is actually buggy and at least the first element of th

  1   2   3   4   5   6   7   8   9   10   >