Re: N-grams

2016-11-09 Thread srinivas devaki
On Thu, Nov 10, 2016 at 12:43 PM, srinivas devaki wrote: > complexity wise it's O(N), but space complexity is O(N**2) to execute > this function, I'm sorry, that is a mistake. I just skimmed through the itertoolsmodule.c, and it seems like the space complexity is just O(N), as when tee objects ar

Re: N-grams

2016-11-09 Thread Paul Rubin
Ian Kelly writes: > I'd use the maxlen argument to deque here. Oh that's cool, it's a Python 3 thing though. > Better to move the extra yield above the loop and reorder the loop > body so that the yielded tuple includes the element just read. Thanks, I'll give that a try. >> if len(d)

Re: Help me cythonize a python routine!

2016-11-09 Thread Steven D'Aprano
On Thursday 10 November 2016 18:23, Andrea D'Amore wrote: > On 10 November 2016 at 00:15, Steve D'Aprano > wrote: >> py> import collections > […] >> py> import os >> py> os.listdir('/usr/local/lib/python3.5/collections/') > > Not > > os.listdir(collections.__path__[0]) > > since it's alrea

Re: [Theory] How to speed up python code execution / pypy vs GPU

2016-11-09 Thread Steven D'Aprano
On Thursday 10 November 2016 17:43, breamore...@gmail.com wrote: > On Thursday, November 10, 2016 at 1:09:31 AM UTC, Steve D'Aprano wrote: >> > > [snipped] > > Steven, there is no need to be rude or condescending. Indeed, and if I thought you were sincere, or knew what you were objecting to,

Re: Help me cythonize a python routine!

2016-11-09 Thread Andrea D'Amore
On 10 November 2016 at 00:15, Steve D'Aprano wrote: > py> import collections […] > py> import os > py> os.listdir('/usr/local/lib/python3.5/collections/') Not os.listdir(collections.__path__[0]) since it's already there? -- Andrea -- https://mail.python.org/mailman/listinfo/python-list

Re: N-grams

2016-11-09 Thread srinivas devaki
> def ngrams(iterable, n=2): > if n < 1: > raise ValueError > t = tee(iterable, n) > for i, x in enumerate(t): > for j in range(i): > next(x, None) > return zip(*t) def myngrams(iterable, n=2): t = list(tee(iterable, 1)) for _ in range(n - 1):

Re: N-grams

2016-11-09 Thread Wolfram Hinderer
Am 10.11.2016 um 03:06 schrieb Paul Rubin: This can probably be cleaned up some: from itertools import islice from collections import deque def ngram(n, seq): it = iter(seq) d = deque(islice(it, n)) if len(d) != n: return for s in

Re: Help me cythonize a python routine!

2016-11-09 Thread Ethan Furman
On 11/09/2016 04:30 PM, Michael Torrie wrote: On 11/09/2016 04:21 PM, Ethan Furman wrote: On 09/11/2016 21:25, breamore...@gmail.com wrote: [...filtered...] Mark, you do not need to be insulting nor condescending. Agreed. Is he still being filtered on the mailing list? He's still in my ki

Re: N-grams

2016-11-09 Thread Ian Kelly
On Wed, Nov 9, 2016 at 7:06 PM, Paul Rubin wrote: > This can probably be cleaned up some: Okay. :-) > from itertools import islice > from collections import deque > > def ngram(n, seq): Looks like "seq" can be any iterable, not just a sequence. > it = iter(seq) > d

I want to insert beacon scan result in to a database using python and mysql

2016-11-09 Thread sudeeratechneed
when this files run gives corresponding output values as; # test BLE Scanning software # jcs 6/8/2014 import MySQLdb as my import blescan import sys import bluetooth._bluetooth as bluez dev_id = 0 db = my.connect(host="localhost", user="root", passwd="root", db="test" ) cursor = db.cursor

Re: Python rules!

2016-11-09 Thread Rustom Mody
On Thursday, November 10, 2016 at 7:02:31 AM UTC+5:30, Skip Montanaro wrote: > > Too bad that the indentation is still not actually significant. One little > > undetectable mistake with the braces and the meaning of the code is > totally > > changed. > > Maybe an Emacs mode which can toggle betwee

Re: Python rules!

2016-11-09 Thread Skip Montanaro
On Wed, Nov 9, 2016 at 7:53 PM, Chris Angelico wrote: > It's called Jython. :) Well, sure, but that didn't look enough like Python, so no chance that I would mistake it for Jython. I suspect that whoever worked out that arrangement of semicolons and braces had some help from her tools. Skip --

Re: N-grams

2016-11-09 Thread Paul Rubin
This can probably be cleaned up some: from itertools import islice from collections import deque def ngram(n, seq): it = iter(seq) d = deque(islice(it, n)) if len(d) != n: return for s in it: yield tuple(d) d.popleft(

Re: Python rules!

2016-11-09 Thread Chris Angelico
On Thu, Nov 10, 2016 at 12:32 PM, Skip Montanaro wrote: > > Maybe an Emacs mode which can toggle between "Java view/mode" (normal) and > "Python view/mode" (Rustom's Twitter example) would be useful. In the > latter, you'd edit the code as if it was Python and see it indebted ask > nice, while it

Re: [Theory] How to speed up python code execution / pypy vs GPU

2016-11-09 Thread Chris Angelico
On Thu, Nov 10, 2016 at 12:16 PM, BartC wrote: > But now that I was about to use it, another problem. The Ubuntu Python is > 2.7. The Windows one has both 2.7 and 3.4 (and my IDE can select either). > > The bit of code I wanted to run has Py3-style print functions. I tried > 'import six' as someon

Re: [Theory] How to speed up python code execution / pypy vs GPU

2016-11-09 Thread BartC
On 10/11/2016 01:16, BartC wrote: I suppose I can get rid of the prints for the test I wanted to do, or find out how to do the same thing under Py2 print. Or install Py3 on Ubuntu, which is a big job and I've no idea how to switch between them. Some good news, it turned out Ubuntu had both Pyt

Re: Python rules!

2016-11-09 Thread Skip Montanaro
> Too bad that the indentation is still not actually significant. One little > undetectable mistake with the braces and the meaning of the code is totally > changed. Maybe an Emacs mode which can toggle between "Java view/mode" (normal) and "Python view/mode" (Rustom's Twitter example) would be us

Re: [Theory] How to speed up python code execution / pypy vs GPU

2016-11-09 Thread BartC
On 10/11/2016 00:38, Michael Torrie wrote: On 11/09/2016 02:10 PM, BartC wrote: Good point, I use Ubuntu under Windows. It should be child's play, except... 'sudo apt-get install numpy' or 'python-numpy' doesn't work. Something is wrong with your setup then. Because both python-numpy and pytho

Re: [Theory] How to speed up python code execution / pypy vs GPU

2016-11-09 Thread Steve D'Aprano
On Thu, 10 Nov 2016 11:38 am, Michael Torrie wrote: > On 11/09/2016 02:10 PM, BartC wrote: >> Good point, I use Ubuntu under Windows. It should be child's play, >> except... 'sudo apt-get install numpy' or 'python-numpy' doesn't work. > > Something is wrong with your setup then. Bart has been

Re: Python rules!

2016-11-09 Thread Ian Kelly
On Nov 9, 2016 5:48 PM, "Michael Torrie" wrote: On 11/09/2016 12:39 PM, jlada...@itu.edu wrote: > On Wednesday, November 9, 2016 at 4:32:15 AM UTC-8, Rustom Mody wrote: >> https://twitter.com/UdellGames/status/788690145822306304 > > It took me a minute to see it. That's insane! Yeah it is... ho

Re: Python rules!

2016-11-09 Thread Michael Torrie
On 11/09/2016 05:54 PM, Chris Angelico wrote: > On Thu, Nov 10, 2016 at 11:42 AM, Michael Torrie wrote: >> On 11/09/2016 12:39 PM, jlada...@itu.edu wrote: >>> On Wednesday, November 9, 2016 at 4:32:15 AM UTC-8, Rustom Mody wrote: https://twitter.com/UdellGames/status/788690145822306304 >>> >>

Re: Python rules!

2016-11-09 Thread Chris Angelico
On Thu, Nov 10, 2016 at 11:42 AM, Michael Torrie wrote: > On 11/09/2016 12:39 PM, jlada...@itu.edu wrote: >> On Wednesday, November 9, 2016 at 4:32:15 AM UTC-8, Rustom Mody wrote: >>> https://twitter.com/UdellGames/status/788690145822306304 >> >> It took me a minute to see it. That's insane! > >

Re: [Theory] How to speed up python code execution / pypy vs GPU

2016-11-09 Thread Chris Angelico
On Thu, Nov 10, 2016 at 11:38 AM, Michael Torrie wrote: > On 11/09/2016 02:10 PM, BartC wrote: >> Good point, I use Ubuntu under Windows. It should be child's play, >> except... 'sudo apt-get install numpy' or 'python-numpy' doesn't work. > > Something is wrong with your setup then. Or with his e

Re: Python rules!

2016-11-09 Thread Michael Torrie
On 11/09/2016 12:39 PM, jlada...@itu.edu wrote: > On Wednesday, November 9, 2016 at 4:32:15 AM UTC-8, Rustom Mody wrote: >> https://twitter.com/UdellGames/status/788690145822306304 > > It took me a minute to see it. That's insane! Yeah it is... however Java actually looks pretty nice without all

Re: [Theory] How to speed up python code execution / pypy vs GPU

2016-11-09 Thread Michael Torrie
On 11/09/2016 02:10 PM, BartC wrote: > Good point, I use Ubuntu under Windows. It should be child's play, > except... 'sudo apt-get install numpy' or 'python-numpy' doesn't work. Something is wrong with your setup then. Because both python-numpy and python3-numpy are in the standard ubuntu reposi

Re: [Theory] How to speed up python code execution / pypy vs GPU

2016-11-09 Thread Chris Angelico
On Thu, Nov 10, 2016 at 8:35 AM, wrote: > I don't actually use pip much myself, I use Synaptic Package Manager. Unless > you need a package from the PSF repository that Canonical doesn't have, > Synaptic should be fine for you. If you want to run the Python3 version of > pip from the command

Re: Help me cythonize a python routine!

2016-11-09 Thread Michael Torrie
On 11/09/2016 04:21 PM, Ethan Furman wrote: >> On 09/11/2016 21:25, breamore...@gmail.com wrote: > > [...filtered...] > > Mark, you do not need to be insulting nor condescending. Agreed. Is he still being filtered on the mailing list? He's still in my killfile. -- https://mail.python.org/mail

Re: is modulefinder.ModuleFinder working at all?

2016-11-09 Thread Steve D'Aprano
On Thu, 10 Nov 2016 08:08 am, Wolfgang Maier wrote: > Hi, > > I just used the stdlib's modulefinder.ModuleFinder (intended to find > modules used by a script) for the first time in my life and it just > doesn't seem to work like documented at all. > Not sure what is going on, but if I try the usa

Re: Help me cythonize a python routine!

2016-11-09 Thread Ethan Furman
On 09/11/2016 21:25, breamore...@gmail.com wrote: [...filtered...] Mark, you do not need to be insulting nor condescending. -- ~Ethan~ -- https://mail.python.org/mailman/listinfo/python-list

Re: Help me cythonize a python routine!

2016-11-09 Thread Steve D'Aprano
On Thu, 10 Nov 2016 10:01 am, BartC wrote: > I haven't ruled out that collections is written in Python. But I can't > find a 'collections.py' module in my Python 3.4; the nearest is > "__init__.py". And there /is/ a lot of code there. And that's exactly right. py> import collections py> collecti

Re: Confused with installing per-user in Windows

2016-11-09 Thread ddbug
@eryk sun: Thank you for useful reply. But note that I don't propose to touch the python interpeters (python*.exe), neither to change anything in how distutils work (about entry points). My proposal is only for the Windows-specific Py launcher. For those who runs python*.exe thru associations o

Re: Help me cythonize a python routine!

2016-11-09 Thread BartC
On 09/11/2016 21:25, breamore...@gmail.com wrote: On Wednesday, November 9, 2016 at 7:34:41 PM UTC, BartC wrote: All the real work is done inside the Collections module. If that was written in Python, then you'd have to Cythonise that, and there might be quite a lot of it! But I think 'collec

Re: What is currently the recommended way to work with a distutils-based setup.py that requires compilation?

2016-11-09 Thread ddbug
I am a Python beginner but would like to contribute $0.02 in absence of authoritative answers (thanks Tim J. for encouragement). After researching this topic for a while, it looks like they now recommend distributing wheels rather than sdist's. For Windows thus is reasonable, given that there i

Re: is modulefinder.ModuleFinder working at all?

2016-11-09 Thread Wolfgang Maier
On 09.11.2016 22:48, Skip Montanaro wrote: I've not used it before, but I suspect it's meant to be used in "freeze" type environments. In that situation, you really do want everything reachable, whether the script imported it or not. Hmm, but that's exactly the problem. It *is* supposed to repo

Re: is modulefinder.ModuleFinder working at all?

2016-11-09 Thread Skip Montanaro
I've not used it before, but I suspect it's meant to be used in "freeze" type environments. In that situation, you really do want everything reachable, whether the script imported it or not. It doesn't take much to wind up importing much of the stdlib either. Try: python -m modulefinder -m /path/t

Re: [Theory] How to speed up python code execution / pypy vs GPU

2016-11-09 Thread jladasky
On Wednesday, November 9, 2016 at 1:10:34 PM UTC-8, BartC wrote: > On 09/11/2016 19:44, j...@i...edu wrote: > Good point, I use Ubuntu under Windows. It should be child's play, > except... 'sudo apt-get install numpy' or 'python-numpy' doesn't work. > > 'pip' doesn't work; it needs to be installe

Re: [Theory] How to speed up python code execution / pypy vs GPU

2016-11-09 Thread BartC
On 09/11/2016 19:44, jlada...@itu.edu wrote: On Wednesday, November 9, 2016 at 5:03:30 AM UTC-8, BartC wrote: On 05/11/2016 17:10, Mr. Wrobel wrote: 1. What I have found is modified python interpreter - pypy - http://pypy.org that does not require any different approach to develop your code.

is modulefinder.ModuleFinder working at all?

2016-11-09 Thread Wolfgang Maier
Hi, I just used the stdlib's modulefinder.ModuleFinder (intended to find modules used by a script) for the first time in my life and it just doesn't seem to work like documented at all. Not sure what is going on, but if I try the usage example from https://docs.python.org/3/library/modulefinde

Re: How to handle errors?

2016-11-09 Thread Bev in TX
On UNIX type systems, the Python installer creates multiple links to the actual Python executable. For example in Python 3.5: python - link to python3.5 python3 - link to python3.5 python3.5 - actual executable Unless your script specifically requires version 3.5, then it is better to use the

RE: data interpolation

2016-11-09 Thread Deborah Swanson
On Thursday, November 03, 2016 3:08 AM, Heli wrote: > I have a question about data interpolation using python. I have a big > ascii file containg data in the following format and around 200M > points. > > id, xcoordinate, ycoordinate, zcoordinate > > then I have a second file containing data

Re: [Theory] How to speed up python code execution / pypy vs GPU

2016-11-09 Thread jladasky
On Wednesday, November 9, 2016 at 5:03:30 AM UTC-8, BartC wrote: > On 05/11/2016 17:10, Mr. Wrobel wrote: > > > 1. What I have found is modified python interpreter - pypy - > > http://pypy.org that does not require any different approach to develop > > your code. > > > > 2. And: Gpu based computi

Re: Python rules!

2016-11-09 Thread jladasky
On Wednesday, November 9, 2016 at 4:32:15 AM UTC-8, Rustom Mody wrote: > https://twitter.com/UdellGames/status/788690145822306304 It took me a minute to see it. That's insane! -- https://mail.python.org/mailman/listinfo/python-list

Re: Help me cythonize a python routine!

2016-11-09 Thread BartC
On 05/11/2016 04:11, DFS wrote: It reads in a text file of the Bible, and counts the Top 20 most common words. http://www.truth.info/download/bible.htm import time; start=time.clock() import sys, string from collections import Counter #read fil

Re: N-grams

2016-11-09 Thread Ian Kelly
On Wed, Nov 9, 2016 at 6:38 AM, Steve D'Aprano wrote: > And here's an implementation for arbitrary n-grams: > > > def ngrams(iterable, n=2): > if n < 1: > raise ValueError > t = tee(iterable, n) > for i, x in enumerate(t): > for j in range(i): > next(x, None

N-grams

2016-11-09 Thread Steve D'Aprano
The documentation for the itertools has this nice implementation for a fast bigram function: from itertools import tee def pairwise(iterable): "s -> (s0,s1), (s1,s2), (s2, s3), ..." a, b = tee(iterable) next(b, None) return zip(a, b) https://docs.python.org/3/library/itertools.h

Re: [Theory] How to speed up python code execution / pypy vs GPU

2016-11-09 Thread BartC
On 05/11/2016 17:10, Mr. Wrobel wrote: 1. What I have found is modified python interpreter - pypy - http://pypy.org that does not require any different approach to develop your code. 2. And: Gpu based computing powered by Nvidia (NumbaPro compiler): https://developer.nvidia.com/how-to-cuda-pyt

Python rules!

2016-11-09 Thread Rustom Mody
https://twitter.com/UdellGames/status/788690145822306304 -- https://mail.python.org/mailman/listinfo/python-list

Re: [Theory] How to speed up python code execution / pypy vs GPU

2016-11-09 Thread Steve D'Aprano
On Wed, 9 Nov 2016 06:35 pm, John Ladasky wrote: [...] > I work a lot with a package called GROMACS, which does highly iterative > calculations to simulate the motions of atoms in complex molecules. > GROMACS can be built to run on a pure-CPU platform (taking advantage of > multiple cores, if you

Re: [Theory] How to speed up python code execution / pypy vs GPU

2016-11-09 Thread Christian Gollwitzer
Am 08.11.16 um 02:23 schrieb Steve D'Aprano: But as far as I know, they [NVidia] 're not the only manufacturer of GPUs, and they are the only ones who support IEEE 754. So this is *exactly* the situation I feared: incompatible GPUs with varying support for IEEE 754 making it difficult or impossi

Re: constructor classmethods

2016-11-09 Thread teppo . pera
keskiviikko 9. marraskuuta 2016 2.25.59 UTC Steve D'Aprano kirjoitti: > On Wed, 9 Nov 2016 10:01 am, teppo...@gmail.com wrote: > > > Generally, with testing, it would be optimal to test outputs of the system > > for given inputs without caring how things are implemented. > > I disagree with that