Survey of Python-in-browser technologies

2013-05-24 Thread Dan Stromberg
I'm putting together a spreadsheet about Python-in-the-browser technologies for my local python user group. I've been hitting the mailing lists for the various implementations already, but I thought I should run it by people here at least once. Anyway, here it is:

Re: Survey of Python-in-browser technologies

2013-05-24 Thread Dan Stromberg
Security is an important topic... but I'm not sure how I could gather info about the security of these implementations. Still, it's an idea worth at least keeping in the back of my mind. On Fri, May 24, 2013 at 4:43 PM, Carlos Nepomuceno carlosnepomuc...@outlook.com wrote: Thanks Dan! All of

Re: Ordered dictionaries compared

2013-05-23 Thread Dan Stromberg
On Thu, May 23, 2013 at 9:41 AM, duncan smith buzzard@invalid.invalidwrote: RBT is quicker than Treap for insertion with randomized data, but slower with ordered data. Randomized data will tend to minimize the number of tree rotations needed to keep the RBT balanced, whilst the Treap will be

Re: Help with implementing callback functions using ctypes

2013-05-23 Thread Dan Stromberg
On Wed, May 8, 2013 at 10:54 PM, dieter die...@handshake.de wrote: jamadagni samj...@gmail.com writes: ... I cannot help you with ctypes. But, if you might be able to use cython, then calling callbacks is not too difficult (you can find an example in e.g. my dm.xmlsec.binding). Note,

Ordered dictionaries compared

2013-05-22 Thread Dan Stromberg
What kind of ordered dictionaries? Sorted by key. I've redone the previous comparison, this time with a better red-black tree implementation courtesy of Duncan G. Smith. The comparison is at http://stromberg.dnsalias.org/~strombrg/python-tree-and-heap-comparison/just-trees/ The Red-Black tree

Re: Modules list-tool

2013-05-22 Thread Dan Stromberg
On Tue, May 21, 2013 at 12:35 PM, Gisle Vanem gva...@broadpark.no wrote: Are anyone aware of a tool that can show me at run-time which modules (pyd/dll) are loaded into a Python program at a specific time (or over time)? To clarify, e.g. when running a sample from PyQt4

TypeError: unbound method add() must be called with BinaryTree instance as first argument (got nothing instead)

2013-05-18 Thread Dan Stromberg
I'm getting the error in the subject, from the following code: def add(self, key): Adds a node containing I{key} to the subtree rooted at I{self}, returning the added node. node = self.find(key) if not node: node.key = key

Re: How to write fast into a file in python?

2013-05-18 Thread Dan Stromberg
With CPython 2.7.3: ./t time taken to write a file of size 52428800 is 15.86 seconds time taken to write a file of size 52428800 is 7.91 seconds time taken to write a file of size 52428800 is 9.64 seconds With pypy-1.9: ./t time taken to write a file of size 52428800 is 3.708232

Re: Red Black Tree implementation?

2013-05-11 Thread Dan Stromberg
15 Thoughts? BTW, printing an empty tree seems to say sentinel. 'not sure if that was intended. Thanks! On Thu, May 9, 2013 at 6:52 AM, duncan smith buzzard@invalid.invalidwrote: On 09/05/13 02:40, Dan Stromberg wrote: OK, I've got one copy of trees.py with md5

Re: Red Black Tree implementation?

2013-05-11 Thread Dan Stromberg
On Sat, May 11, 2013 at 4:24 PM, Dan Stromberg drsali...@gmail.com wrote: I'm afraid I'm having some trouble with the module. I've checked it into my SVN at http://stromberg.dnsalias.org/svn/red-black-tree-mod/trunk/duncan I have two versions of your tests in there now - t is minimally

Re: Red Black Tree implementation?

2013-05-08 Thread Dan Stromberg
OK, I've got one copy of trees.py with md5 211f80c0fe7fb9cb42feb9645b4b3ffe. You seem to be saying I should have two though, but I don't know that I do... On 5/8/13, duncan smith buzzard@invalid.invalid wrote: On 07/05/13 02:20, Dan Stromberg wrote: On Mon, May 6, 2013 at 5:55 PM, duncan

Re: Making safe file names

2013-05-07 Thread Dan Stromberg
On 5/7/13, Andrew Berg bahamutzero8...@gmail.com wrote: Currently, I keep Last.fm artist data caches to avoid unnecessary API calls and have been naming the files using the artist name. However, artist names can have characters that are not allowed in file names for most file systems (e.g.,

Re: Red Black Tree implementation?

2013-05-06 Thread Dan Stromberg
On Mon, May 6, 2013 at 5:55 PM, duncan smith buzzard@invalid.invalidwrote: What license? Thanks! Here's the text I usually prepend. ##Copyright (c) 2013 duncan g. smith ## ##Permission is hereby granted, free of charge, to any person obtaining a ##copy of this software and associated

Re: Red Black Tree implementation?

2013-05-02 Thread Dan Stromberg
On Thu, May 2, 2013 at 3:46 AM, Christian Heimes christ...@python.orgwrote: Am 02.05.2013 01:11, schrieb Dan Stromberg: No wonder it's getting slow and doesn't stand a change against Python's dict implementation. The rbtree implementation from newcenturycomputers.net is written entirely

Re: Red Black Tree implementation?

2013-05-02 Thread Dan Stromberg
On Wed, May 1, 2013 at 7:06 PM, duncan smith buzzard@invalid.invalidwrote: I have an implementation that you can try out. It's not based on any other implementation, so my bugs will be independent of any bugs in the code you're currently using. It looks more like a set - add, remove, discard.

Red Black Tree implementation?

2013-05-01 Thread Dan Stromberg
What's the best Red Black Tree implementation for Python with an opensource license? I started out looking at http://newcenturycomputers.net/projects/rbtree.htmlbecause it was pretty high in Google and had the operators I wanted, but it gets very slow at about half a million elements. I've been

Re: Reading a CSV file

2013-04-23 Thread Dan Stromberg
On Tue, Apr 23, 2013 at 2:39 PM, Ana Dionísio anadionisio...@gmail.comwrote: Hello! I need to read a CSV file that has n rows and m columns and if a certain condition is met, for exameple n==200, it prints all the columns in that row. How can I do this? I tried to save all the data in a

Re: Reading a CSV file

2013-04-23 Thread Dan Stromberg
On Tue, Apr 23, 2013 at 2:58 PM, Ana Dionísio anadionisio...@gmail.comwrote: Thank you, but can you explain it a little better? I am just starting in python and I don't think I understood how to apply your awnser -- http://mail.python.org/mailman/listinfo/python-list

Re: optomizations

2013-04-22 Thread Dan Stromberg
On Mon, Apr 22, 2013 at 6:53 PM, Roy Smith r...@panix.com wrote: So, my real advice to you is to fire up the profiler and see what it says. I agree. Fire up a line-oriented profiler and only then start trying to improve the hot spots. -- http://mail.python.org/mailman/listinfo/python-list

Re: Performance of int/long in Python 3

2013-03-25 Thread Dan Stromberg
On Mon, Mar 25, 2013 at 4:35 PM, Cousin Stanley cousinstan...@gmail.comwrote: Chris Angelico wrote: The Python 3 merge of int and long has effectively penalized small-number arithmetic by removing an optimization. The cost is clear. I thought I heard that Python 3.x will

Re: Is Python programming language?

2013-02-11 Thread Dan Stromberg
Sent from my android phone. On Feb 9, 2013 6:41 PM, Terry Reedy tjre...@udel.edu wrote: On 2/9/2013 6:53 PM, Michael Torrie wrote: On 02/09/2013 04:26 PM, Tim Roberts wrote: Most people would call bash a scripting language, but it is also clearly a programming language. It has syntax,

Re: Python3 curses behavior

2013-02-11 Thread Dan Stromberg
Sent from my android phone. On Feb 10, 2013 2:09 PM, Vlasov Vitaly vnig...@gmail.com wrote: суббота, 9 февраля 2013 г., 23:22:47 UTC+4 пользователь Terry Reedy написал: On 2/9/2013 6:23 AM, Vlasov Vitaly wrote: -- Terry Jan Reedy Thank you. I tried everything in my test script.

Re: Opinion on best practice...

2013-02-05 Thread Dan Stromberg
On Feb 5, 2013 6:00 PM, Steven Dapos;Aprano steve+comp.lang.pyt...@pearwood.info wrote: Chris Angelico wrote: Python is not an excellent option. It's a bad fit for shell scripting, it just happens to be way better than a weak shell. Having grown up on command.com, I found OS/2's cmd.exe

Building python, bz2 coming up missing

2012-11-21 Thread Dan Stromberg
I'm attempting to build cpython 2.{5,6,7} and cpython 3.[0,1,2,3}. I find that having them all around facilitates interversion testing and discovering what works in which versions. Anyway, in 3.3, I'm getting a bz2 module, but in 3.2, I'm not - but only when compiling on Linux Mint 14. On Linux

Re: Building python, bz2 coming up missing

2012-11-21 Thread Dan Stromberg
On Wed, Nov 21, 2012 at 12:18 PM, Dan Stromberg drsali...@gmail.com wrote: I'm attempting to build cpython 2.{5,6,7} and cpython 3.[0,1,2,3}. I find that having them all around facilitates interversion testing and discovering what works in which versions. Anyway, in 3.3, I'm getting a bz2

Re: bit count or bit set Python3

2012-10-25 Thread Dan Stromberg
On Thu, Oct 25, 2012 at 9:24 AM, Mark Lawrence breamore...@yahoo.co.ukwrote: On 25/10/2012 15:47, Charles Hixson wrote: In Python3 is there any good way to count the number of on bits in an integer (after an operation)? Alternatively, is there any VERY light-weight implementation of a bit

Good debugger for CPython 3.2?

2012-10-19 Thread Dan Stromberg
What's a good debugger for CPython 3.2? I'd prefer to use it on Linux Mint 13, and I'd be happy with something based on X11 or curses. I tried winpdb, but it was cranky that Linux didn't have a spawn callable. Why they didn't use the portable subprocess module escapes me. I also tried ddd, but

Re: Good debugger for CPython 3.2?

2012-10-19 Thread Dan Stromberg
On Fri, Oct 19, 2012 at 9:26 AM, Dan Stromberg drsali...@gmail.com wrote: What's a good debugger for CPython 3.2? I'd prefer to use it on Linux Mint 13, and I'd be happy with something based on X11 or curses. I tried winpdb, but it was cranky that Linux didn't have a spawn callable. Why

Re: A desperate lunge for on-topic-ness

2012-10-18 Thread Dan Stromberg
On Wed, Oct 17, 2012 at 11:06 PM, Zero Piraeus sche...@gmail.com wrote: : Okay, so, first thing vaguely Python-related that comes to mind [so probably not even slightly original, but then that's not really the point]: What are people's preferred strategies for dealing with lines that go

Static analysis tools

2012-10-11 Thread Dan Stromberg
I'm familiar with pylint, and have recently played with pyflakes and flake8. I've also heard of pychecker. Are there others, perhaps including some that aren't written in Python, but still check Python? We're considering doing static analysis of a large CPython 3.2 project, but so far the

Reimporting modules, and sandboxing?

2012-08-21 Thread Dan Stromberg
I know I've seen this discussed before, and I came away from observing the discussion thinking Python doesn't do that very well..., but we have some people here who really would like to do this, and I need to better understand the pros and cons now. Is there a good way of reimporting an

Re: python 6 compilation failure on RHEL

2012-08-20 Thread Dan Stromberg
On Mon, Aug 20, 2012 at 10:25 PM, Cameron Simpson c...@zip.com.au wrote: I was going to chime in with this anyway had the thread said nothing; I strongly prefer to specify --prefix explicitly with configure. My personal habit to to build with (adjust to match):

Re: trying to create simple py script

2012-08-10 Thread Dan Stromberg
CGI's old stuff. Sure it's easy to find doc about it - it's been around longer. I'd recommend either CherryPy or Bottle - because these are the two (that I know of) that support Python 3 today. Here's a nice comparison of Python REST frameworks: http://www.youtube.com/watch?v=AYjPIMe0BhA I'm

Re: Threads and sockets

2012-08-10 Thread Dan Stromberg
A select() loop should work. On Fri, Aug 10, 2012 at 1:01 PM, loial jldunn2...@gmail.com wrote: I am writing an application to send data to a printer port(9100) and then recieve PJL responses back on that port. Because of the way PJL works I have to do both in the same process(script). At

Re: Unable to execute the script

2012-08-10 Thread Dan Stromberg
This sounds like a ScriptAlias thing: http://httpd.apache.org/docs/2.2/howto/cgi.html On Fri, Aug 10, 2012 at 5:14 PM, Smaran Harihar smaran.hari...@gmail.comwrote: Hi, I have set executable permissions for my py script (cgi-script) but for some reason rather than executing it, the browser

Re: Extracting bit fields from an IEEE-784 float

2012-07-30 Thread Dan Stromberg
On Mon, Jul 30, 2012 at 12:44 AM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: I wish to extract the bit fields from a Python float, call it x. First I cast the float to 8-bytes: s = struct.pack('=d', x) i = struct.unpack('=q', s)[0] Then I extract the bit fields from the

Re: Linux shell to python

2012-07-30 Thread Dan Stromberg
On Mon, Jul 30, 2012 at 9:26 PM, Barry Scott ba...@barrys-emacs.org wrote: lspci gets all its information from the files in /sys/bus/pci/devices. You can use os.listdir() to list all the files in the folder and then open the files you want to get the data you need. Gee, wouldn't it be more

Re: Linux shell to python

2012-07-30 Thread Dan Stromberg
On Mon, Jul 30, 2012 at 11:14 PM, Emile van Sebille em...@fenx.com wrote: On 7/30/2012 3:56 PM Dan Stromberg said... On Mon, Jul 30, 2012 at 9:26 PM, Barry Scott ba...@barrys-emacs.org And of course you can write list comprehensions on as many lines as it take to make the code

Re: Is Python a commercial proposition ?

2012-07-29 Thread Dan Stromberg
On Sun, Jul 29, 2012 at 5:52 PM, Andrew Berg bahamutzero8...@gmail.comwrote: On 7/29/2012 7:12 PM, Rodrick Brown wrote: Python is a glue language much like Perl was 10 years ago. Until the GIL is fixed I doubt anyone will seriously look at Python as an option for large enterprise

Re: dict: keys() and values() order guaranteed to be same?

2012-07-26 Thread Dan Stromberg
On Thu, Jul 26, 2012 at 9:06 PM, Ethan Furman et...@stoneleaf.us wrote: Chris Angelico wrote: On Tue, Jul 24, 2012 at 1:20 AM, Steven D'Aprano steve+comp.lang.python@**pearwood.infosteve%2bcomp.lang.pyt...@pearwood.info wrote: (Although if you think about the implementation of dicts as

Re: howto do a robust simple cross platform beep

2012-07-24 Thread Dan Stromberg
On Sat, Jul 14, 2012 at 1:00 AM, Gelonida N gelon...@gmail.com wrote: What I do at the moment is: For Windows I use winsound.Beep For Linux I create some raw data and pipe it into sox's 'play' command. I don't consider this very elegant You may want to get over that. Some software

command line option parsing and pylint?

2012-07-22 Thread Dan Stromberg
Is there such a thing as a Python option parsing module, that plays well with pylint? I've been doing my own option parsing to get working static analysis. -- http://mail.python.org/mailman/listinfo/python-list

default repr?

2012-07-22 Thread Dan Stromberg
If a class has defined its own __repr__ method, is there a way of getting the default repr output for that class anyway? I'm attempting to graph some objects by digging around in the garbage collector's idea of what objects exist, and when I go to format them for the graph node labels, the ones

Re: PyPy, is it a 1:1 replacement for CPython?

2012-07-20 Thread Dan Stromberg
On Fri, Jul 20, 2012 at 8:59 PM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: On Sat, 21 Jul 2012 13:35:21 +1000, Simon Cropper wrote: Hi, Can you use PyPy as a direct replacement for the normal python or is it a specialized compiler that can only work with libraries

Re: lambda in list comprehension acting funny

2012-07-14 Thread Dan Stromberg
On Sat, Jul 14, 2012 at 4:29 PM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: I don't remember whether it is Javascript or PHP that uses dynamic binding, but whichever it is, it is generally considered to be a bad idea, at least as the default or only behaviour. Bash is

Re: How to safely maintain a status file

2012-07-09 Thread Dan Stromberg
On Mon, Jul 9, 2012 at 8:24 PM, John Nagle na...@animats.com wrote: On 7/8/2012 2:52 PM, Christian Heimes wrote: You are contradicting yourself. Either the OS is providing a fully atomic rename or it doesn't. All POSIX compatible OS provide an atomic rename functionality that renames the

Re: Best data structure for DFS on large graphs

2012-07-03 Thread Dan Stromberg
On Tue, Jul 3, 2012 at 3:08 PM, Miheer Dewaskar miheer@gmail.comwrote: On Tue, Jul 3, 2012 at 8:10 PM, Tim Chase python.l...@tim.thechases.com wrote: I want it to be a generic Game solver.So the number of states depends on the game. Keep in mind that it would probably be a generic game

Why site-packages?

2012-07-03 Thread Dan Stromberg
Why is it that so much 3rd party python code gets installed to site-packages? Even for things that are almost certainly going to be used by a single application? Even for things you might only use once? Even for things that might require one version for one app, and another version for another

Re: Why site-packages?

2012-07-03 Thread Dan Stromberg
On Tue, Jul 3, 2012 at 9:04 PM, Ian Kelly ian.g.ke...@gmail.com wrote: On Tue, Jul 3, 2012 at 2:40 PM, Dan Stromberg drsali...@gmail.com wrote: Why is it that so much 3rd party python code gets installed to site-packages? Because that's what site-packages is for? Agh. But -why

Re: Why site-packages?

2012-07-03 Thread Dan Stromberg
On Tue, Jul 3, 2012 at 10:04 PM, Ian Kelly ian.g.ke...@gmail.com wrote: The site module has to process any .pth files in the site-packages, but apart from that, I think the actual amount of stuff in site-packages should be irrelevant. Irrelevant to what? More stuff in site slowing

Re: when normal parallel computations in CPython will be implemented at last?

2012-07-01 Thread Dan Stromberg
If something happens with this for CPython, it'll likely come from Pypy developers first. They seem to be interested in doing things in a way that is (or can be made) compatible with CPython. If you want to help them along, they're taking donations to fund the work, or you could donate your own

Re: when normal parallel computations in CPython will be implemented at last?

2012-07-01 Thread Dan Stromberg
On Sun, Jul 1, 2012 at 11:58 AM, Thomas Jollans t...@jollybox.de wrote: On 07/01/2012 08:44 PM, Dan Stromberg wrote: IronPython, sadly, lacks a python standard library. Beg pardon? https://github.com/IronLanguages/main/tree/master/External.LCA_RESTRICTED/Languages/IronPython/27/Lib

Re: How keep python socket alive for ever by setting Keep alive flag.

2012-06-25 Thread Dan Stromberg
http://www.unixguide.net/network/socketfaq/4.7.shtml It's better to add the ability to recreate a socket if it encounters trouble. SO_KEEPALIVE is there to help you detect if the other end of your connection has disappeared. Network programming has relatively few absolutes - it's best to build

Re: How does python bytecode works?

2012-06-17 Thread Dan Stromberg
On Sun, Jun 17, 2012 at 2:54 AM, gmspro gms...@yahoo.com wrote: We know python is written in C. Yes, at least CPython is. Of course, java is written in C, as are many other languages. C is not portable. C gives you lots of rope to hang yourself with, but if you use C well, it's more

Import semantics?

2012-06-08 Thread Dan Stromberg
Did the import semantics change in cpython 3.3a4? I used to be able to import treap.py even though I had a treap directory in my cwd. With 3.3a4, I have to rename the treap directory to see treap.py. -- http://mail.python.org/mailman/listinfo/python-list

Re: Import semantics?

2012-06-08 Thread Dan Stromberg
On Fri, Jun 8, 2012 at 3:16 PM, Ethan Furman et...@stoneleaf.us wrote: Dan Stromberg wrote: Did the import semantics change in cpython 3.3a4? I used to be able to import treap.py even though I had a treap directory in my cwd. With 3.3a4, I have to rename the treap directory to see

Re: Import semantics?

2012-06-08 Thread Dan Stromberg
On Fri, Jun 8, 2012 at 3:48 PM, Ian Kelly ian.g.ke...@gmail.com wrote: On Fri, Jun 8, 2012 at 4:24 PM, Dan Stromberg drsali...@gmail.com wrote: Am I misinterpreting this? It seems like according to the PEP, I should have still been able to import treap.py despite having a treap/. But I

Re: Import semantics?

2012-06-08 Thread Dan Stromberg
And a link to the ticket: http://bugs.python.org/issue15039 -- http://mail.python.org/mailman/listinfo/python-list

[issue15039] module/ found before module.py when both are in the CWD

2012-06-08 Thread Dan Stromberg
New submission from Dan Stromberg strom...@gmail.com: CPython 3.3a4 appears to find treap/ before treap.py in the CWD. If I rename treap to treap-dir, all seems well for the code in question: dstromberg@zareason-limbo6000a /tmp/tt $ mv treap treap-dir dstromberg@zareason-limbo6000a /tmp/tt

Python Tree datastructure comparison

2012-06-05 Thread Dan Stromberg
I've put together a comparison of some tree datastructures for Python, with varied runtime and varied workload: http://stromberg.dnsalias.org/~strombrg/python-tree-and-heap-comparison/ I hope to find time to add heaps to the article at some point, but for now, it only covers trees and the treap.

Re: Please use the Python Job Board for recruiting

2012-05-23 Thread Dan Stromberg
On Wed, May 23, 2012 at 2:27 AM, Jean-Michel Pichavant jeanmic...@sequans.com wrote: Dan Stromberg wrote: On Tue, May 22, 2012 at 3:20 PM, Ben Finney ben+pyt...@benfinney.id.aumailto: ben+python@benfinney.**id.au ben%2bpyt...@benfinney.id.au wrote: Python Recruiter ro...@omniumit.com

Re: Please use the Python Job Board for recruiting

2012-05-23 Thread Dan Stromberg
On Wed, May 23, 2012 at 3:30 AM, Chris Withers ch...@python.org wrote: On 23/05/2012 00:34, Dan Stromberg wrote: I find it more than a little disappointing that the Python Job Board doesn't do latitude and longitude. It's a big missed opportunity. Yes, it's not an identical process from

Re: Please use the Python Job Board for recruiting (was: Recruiting for Python Developer - Perm)

2012-05-22 Thread Dan Stromberg
On Tue, May 22, 2012 at 3:20 PM, Ben Finney ben+pyt...@benfinney.id.auwrote: Python Recruiter ro...@omniumit.com writes: Can any one help? I am looking for a Senior Python Developer Yes, please use the Python Job Board for this purpose instead URL:http://www.python.org/community/jobs/.

Re: install python 2.6 on Ubuntu 12.04

2012-05-22 Thread Dan Stromberg
If the pythons you require are in synaptic (sudo to root and run synaptic), you probably can just use them. If not, then you, for each release, need to: 1) download a tarball using a browser or whatever 2) extract the tarball: tar xvfp foo.tar.bz2 3) cd into the newly created, top-level

Re: bash/shell to python

2012-05-21 Thread Dan Stromberg
FWIW, I do manual argument parsing, because pylint understands how to detect typos with manual argument parsing, but not the highly dynamic modules that parse arguments. On Wed, May 16, 2012 at 7:16 PM, Rita rmorgan...@gmail.com wrote: Hello, I currently build a lot of interfaces/wrappers to

Re: tee-like behavior in Python

2012-05-09 Thread Dan Stromberg
You've had some good responses already, but here're two more: 1) Easiest would be to use setvbuf in the child process, if you have access to its source. This allows you to force line-oriented buffering. 2) stdio likes to buffer to tty/pty's in a line-oriented manner, and other things in a

Re: sorting 1172026 entries

2012-05-06 Thread Dan Stromberg
How much physical RAM (not the virtual memory, but the physical memory) does your machine have available? We know the number of elements in your dataset, but how big are the individual elements? If a sort is never completing, you're probably swapping. list.sort() is preferrable to sorted(list),

Re: Is Python Lazy?

2012-05-05 Thread Dan Stromberg
Generators and iterators are laziness where you tend to need laziness the most. Generator expressions are tiny generators - more full fledged generators are supported. Python probably won't have laziness at its core ever, but it's nice having a dose of it. IOW, you probably won't be able to

Re: key/value store optimized for disk storage

2012-05-04 Thread Dan Stromberg
On Thu, May 3, 2012 at 11:03 PM, Paul Rubin no.email@nospam.invalid wrote: Sort of as you suggest, you could build a Huffman encoding for a representative run of data, save that tree off somewhere, and then use it for all your future encoding/decoding. Zlib is better than Huffman in my

Re: Lack of whitespace between contain operator (in) and other expression tokens doesn't result in SyntaxError: bug or feature?

2012-05-03 Thread Dan Stromberg
On Thu, May 3, 2012 at 12:21 PM, Garrett Cooper yaneg...@gmail.com wrote: On Thu, May 3, 2012 at 12:03 PM, Ian Kelly ian.g.ke...@gmail.com wrote: On Thu, May 3, 2012 at 12:49 PM, Garrett Cooper yaneg...@gmail.com wrote: I was wondering whether this was a parser bug or feature (seems

Re: When convert two sets with the same elements to lists, are the lists always going to be the same?

2012-05-03 Thread Dan Stromberg
If you need the same ordering in two lists, you really should sort the lists - though your comparison function need not be that traditional. You might be able to get away with not sorting sometimes, but on CPython upgrades or using different Python interpreters (Pypy, Jython), it's almost certain

Re: Sort comparison

2012-05-01 Thread Dan Stromberg
On Tue, May 1, 2012 at 12:21 AM, Ian Kelly ian.g.ke...@gmail.com wrote: On Mon, Apr 30, 2012 at 11:25 PM, Dan Stromberg drsali...@gmail.com wrote: A while back I did a sort algorithm runtime comparison for a variety of sorting algorithms, and then mostly sat on it. Recently, I got

Re: Sort comparison

2012-05-01 Thread Dan Stromberg
On Tue, May 1, 2012 at 10:51 AM, Terry Reedy tjre...@udel.edu wrote: On 5/1/2012 1:25 AM, Dan Stromberg wrote: Anyway, here's the comparison, with code and graph: http://stromberg.dnsalias.org/**~strombrg/sort-comparison/http://stromberg.dnsalias.org/%7Estrombrg/sort-comparison/ (It's done

Re: Sort comparison

2012-05-01 Thread Dan Stromberg
On Tue, May 1, 2012 at 11:52 AM, Ian Kelly ian.g.ke...@gmail.com wrote: On Tue, May 1, 2012 at 12:00 PM, Dan Stromberg drsali...@gmail.com wrote: On Tue, May 1, 2012 at 12:21 AM, Ian Kelly ian.g.ke...@gmail.com wrote: On Mon, Apr 30, 2012 at 11:25 PM, Dan Stromberg drsali...@gmail.com

Sort comparison

2012-04-30 Thread Dan Stromberg
A while back I did a sort algorithm runtime comparison for a variety of sorting algorithms, and then mostly sat on it. Recently, I got into a discussion with someone on stackoverflow about the running time of radix sort. I realize it's commonly said that radixsort is n*k rather than n*log(n).

Re: Suggest design to accomodate non-unix platforms ?

2012-04-20 Thread Dan Stromberg
On Thu, Apr 19, 2012 at 5:14 PM, Chris Angelico ros...@gmail.com wrote: The question then is whether to choose or auto-detect. Attempting to auto-detect could be quite inefficient; imagine if you have to call on ssh every couple of seconds, and something in $PATH is on a slow network share

Re: Suggest design to accomodate non-unix platforms ?

2012-04-19 Thread Dan Stromberg
On Wed, Apr 18, 2012 at 5:16 PM, Miki Tebeka miki.teb...@gmail.com wrote: So I'm interested in suggestions/examples where a user can update a config file to specify by which means they want (in this case) the ssh functionality to be supplied. You can do something like that (it's called a

Re: How to determine if IO redirection is occurring with the output from a Python program?

2012-04-18 Thread Dan Stromberg
On Tue, Apr 17, 2012 at 5:52 PM, Chris Angelico ros...@gmail.com wrote: isatty() is supported on Windows (the underlying C API is different, but the beauty of a high-level language is that you no longer need to care), but the standard Windows console doesn't support ANSI sequences. I think

Re: Suggest design to accomodate non-unix platforms ?

2012-04-18 Thread Dan Stromberg
On Wed, Apr 18, 2012 at 7:02 AM, Richard Shea shearich...@gmail.com wrote: On Apr 19, 1:56 am, Irmen de Jong irmen.nos...@xs4all.nl wrote: On 18-4-2012 15:35, Richard Shea wrote: ... which I think would work and be sufficiently flexible to deal with alternatives to putty.exe but is

Re: Is it possible develop applications in python for android and which IDE could you recommend me (Eclipse, ...)???

2012-04-12 Thread Dan Stromberg
http://code.google.com/p/android-scripting/ However, I've not used it, and I'm told it requires a stub for each new android method exposed to python. I find it a little regrettable that they didn't start frp, jython or pypy for jvm instead of cpython, to avoid all the stubbing. On Thu, Apr 12,

Re: Sockets accept() in child processes

2012-04-12 Thread Dan Stromberg
I wonder if this'll do what you need: https://trac.calendarserver.org/browser/CalendarServer/trunk/twext/python/sendfd.py On Thu, Apr 12, 2012 at 2:31 AM, Thibaut DIRLIK merwin@gmail.comwrote: Hi, I'm writing a multiprocess server with Python 3.2 and the multiprocessing module. Here is

Re: Problem connecting to SMTP/IMAP server using SSL

2012-04-12 Thread Dan Stromberg
Are you quite sure that your iPhone isn't using some sort of VPN? On my Android phone, I need a VPN client to access my work mail, but I install it once and forget about it; it doesn't require me to enter my password more than once. On Fri, Mar 30, 2012 at 10:39 PM, Julien jpha...@gmail.com

Re: Problem connecting to SMTP/IMAP server using SSL

2012-04-12 Thread Dan Stromberg
Maybe it's a matter of two different protocols, one requiring a VPN, one not. You could perhaps try a sniffer to check that out. Where to place the sniffer could be complicated though. On Fri, Mar 30, 2012 at 10:39 PM, Julien jpha...@gmail.com wrote: Hi, I'm able to connect to an Exchange

Re: Sockets accept() in child processes

2012-04-12 Thread Dan Stromberg
On Thu, Apr 12, 2012 at 10:48 AM, Merwin merwin@gmail.com wrote: Le 12/04/2012 19:10, Dan Stromberg a écrit : I wonder if this'll do what you need: https://trac.calendarserver.**org/browser/CalendarServer/** trunk/twext/python/sendfd.pyhttps://trac.calendarserver.org/browser

Re: red-black tree data structure

2012-04-11 Thread Dan Stromberg
Bringing this back to Python a bit: http://newcenturycomputers.net/projects/rbtree.html http://pypi.python.org/pypi/bintrees/0.3.0 http://pypi.python.org/pypi/treap/0.995 Red-Black trees are supposed to be slower than treaps on average, but they're also supposed to have a lower standard

Re: Python randomly exits with Linux OS error -9 or -15

2012-04-09 Thread Dan Stromberg
You might try running your Python process with: strace -f -s 1024 -o /tmp/script.strace python /path/to/script.py Then you (perhaps with a C programmer) can likely track down what happened right before the crash by examining the system call tracer near the end of the file.

Re: How do I use PyGTK to put text besides clickable buttons?

2012-04-02 Thread Dan Stromberg
You could use an hbox. Or rather, a vbox with a bunch of hbox's in it. On Thu, Mar 29, 2012 at 10:45 PM, Jason Hsu, Mr. Swift Linux jhsu802...@gmail.com wrote: I've decided to use PyGTK instead of gtkdialog for providing configuration menus/dialog boxes in Swift Linux, the Linux distro I

Re: Does anyone actually use PyPy in production?

2012-03-17 Thread Dan Stromberg
I personally feel that python-list should be restricted to discussing Python the language, not just CPython the implementation. Anyway, there are many kinds of production, no? But I use Pypy for my backups frequently, which is a form of production use. Pypy+backshift pass my automated tests as

Re: cannot open shared object file

2012-03-16 Thread Dan Stromberg
A suggestion: 1) strace it. http://stromberg.dnsalias.org/~strombrg/debugging-with-syscall-tracers.html 2) Show the output to a C programmer, or take some educated guesses yourself. On Thu, Mar 15, 2012 at 11:47 PM, Steven Lo s...@hep.caltech.edu wrote: ** Hi, We are getting the following

Re: Fast file data retrieval?

2012-03-12 Thread Dan Stromberg
If the ID's are sorted, you could probably rig a binary search using seek. This'll be easier if the records have a constant length, but it's still possible for variable-length, just messier. Otherwise you could stash them all in a dictionary (in memory) or anydbm (on disk) to get indexed access.

Re: Parse cisco's show ip route output in Python 2.7

2012-03-04 Thread Dan Stromberg
I've done little with Ciscos, but what if you use individual things like show ip ospf, show ip rip database, etc. instead of show ip route. Does that makes things a little more consistent? Often big problems are simpler if we can divide them into smaller, more manageable subproblems. On Sun,

Re: Porting Python to an embedded system

2012-03-04 Thread Dan Stromberg
You might check out pymite. http://wiki.python.org/moin/PyMite Oh, but I'm now realizing that's part of the python on a chip project, so in a way it's already been mentioned. Anyway, PyMite, I gather, is a tiny python for microcontrollers. On Sun, Mar 4, 2012 at 2:58 AM, Justin Drake

Re: lang comparison: in-place algorithm for reversing a list in Perl, Python, Lisp

2012-02-29 Thread Dan Stromberg
On Wed, Feb 29, 2012 at 8:07 PM, Xah Lee xah...@gmail.com wrote: fun example. in-place algorithm for reversing a list in Perl, Python, Lisp http://xahlee.org/comp/in-place_algorithm.html plain text follows What's “In-place Algorithm”? Xah Lee,

Re: [semi OT]: Smartphones and Python?

2012-02-20 Thread Dan Stromberg
On Wed, Feb 15, 2012 at 3:36 PM, Paul Rubin no.email@nospam.invalid wrote: Martin Schöön martin.sch...@gmail.com writes: A very quick internet search indicated that this should be no big deal if I go for an Android-based phone. What about the alternatives? It works pretty well with Maemo,

Re: Where to put data

2012-01-26 Thread Dan Stromberg
I think that /usr/*/python-whatever/site-packages and related directories are very much overused in the python world, and tend to cause problems eventually - EG when you need to install two versions of a program on the same machine, same interpreter. I prefer to provide a configure script that

How safe is this way of getting a default that allows None?

2011-12-25 Thread Dan Stromberg
How safe is this? I like the idea. #!/usr/bin/python UNSPECIFIED = object() def fn(x, y=UNSPECIFIED): if y is UNSPECIFIED: print x, 'default' else: print x, y fn(0, 1) fn(0, None) fn(0) -- http://mail.python.org/mailman/listinfo/python-list

Re: Multiprocessing: killing children when parent dies

2011-12-07 Thread Dan Stromberg
On 12/7/11, Mihai Badoiu mbad...@gmail.com wrote: ok, so the code is something like #process A p = Process(...) p.daemon = 1 p.start() # starts process B ... If process A dies (say error, or ctrl-c), or finishes, then process B also dies. But if process A is killed with the kill

Re: Hints for writing bit-twiddling code in Python

2011-12-06 Thread Dan Stromberg
On 12/6/11, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: I have some bit-twiddling code written in Java which I am trying to port to Python.: long newSeed = (seed 0xL) * 0x41A7L; while (newSeed = 0x8000L) { newSeed = (newSeed 0x7FFFL) + (newSeed 31L);

Re: order independent hash?

2011-12-05 Thread Dan Stromberg
On 12/5/11, 8 Dihedral dihedral88...@googlemail.com wrote: On Monday, December 5, 2011 1:50:08 PM UTC+8, Dan Stromberg wrote: Two methods: 1) If you need your hash only once in an infrequent while, then save the elements in a list, appending as needed, and sort prior to hashing, as needed

Re: order independent hash?

2011-12-04 Thread Dan Stromberg
Two methods: 1) If you need your hash only once in an infrequent while, then save the elements in a list, appending as needed, and sort prior to hashing, as needed 2) If you need your hash more often, you could keep your elements in a treap or red-black tree; these will maintain sortedness

<    1   2   3   4   5   6   7   8   9   10   >