pyNVML - GPU Monitoring and Management

2012-04-27 Thread Robert Alexander
I'm pleased to announce the release of pyNVML 3.295: Python Bindings for the NVIDIA Management Library. pyNVML provides programmatic access to static information and monitoring data for NVIDIA GPUs, as well as management capabilities. It exposes the functionality of the NVML library. See

ANN: eGenix mxODBC - Python ODBC Database Interface 3.1.2

2012-04-27 Thread eGenix Team: M.-A. Lemburg
ANNOUNCING eGenix.com mxODBC - Python ODBC Database Interface Version 3.1.2 mxODBC is our commercially supported Python extension providing ODBC database connectivity to

Re: cmd2, an extenstion of cmd that parses its argument list

2012-04-27 Thread anntzer . lee
On Sunday, March 18, 2012 10:12:24 PM UTC-7, anntz...@gmail.com wrote: Dear all, I would like to announce the first public release of cmd2, an extension of the standard library's cmd with argument parsing, here: https://github.com/anntzer/cmd2. Due to an already existing Cmd2 on PyPI, I

Re: why () is () and [] is [] work in other way?

2012-04-27 Thread Paul Rubin
Steven D'Aprano steve+comp.lang.pyt...@pearwood.info writes: I'm seeing code generated by the Haskell GHC compiler being 2-4 times slower than code from the C gcc compiler, and on average using 2-3 times as much memory (and as much as 7 times). Alioth isn't such a great comparison, because

RE: Set Date and Time on Python

2012-04-27 Thread Shambhu Rajak
-Original Message- From: Dave Angel [mailto:d...@davea.name] Sent: 26/04/2012 4:31 PM To: viral shah Cc: python-list@python.org Subject: Re: Set Date and Time on Python On 04/26/2012 03:09 AM, viral shah wrote: Hi I'm very new to Python programming. Please help me to add date and

Re: (3.2) Overload print() using the C API?

2012-04-27 Thread Stefan Behnel
Peter Faulks, 26.04.2012 21:28: All you have to do is assign to print. Sounds great! Can some kind soul hit me with a clue stick? Were do I look in the API? Here's the (Py3) Cython code for it: print = my_print_function Stefan -- http://mail.python.org/mailman/listinfo/python-list

Re: (3.2) Overload print() using the C API?

2012-04-27 Thread Stefan Behnel
Peter Faulks, 26.04.2012 19:57: I want to extend an embedded interpreter so that calls to print() are automagically sent to a C++ gui (windows exe) via a callback function in the DLL. Then I'll be able to do this: test.py import printoverload printoverload.set_stdout()

Re: (3.2) Overload print() using the C API?

2012-04-27 Thread Peter Faulks
On 27/04/2012 5:15 PM, Stefan Behnel wrote: Peter Faulks, 26.04.2012 19:57: I want to extend an embedded interpreter so that calls to print() are automagically sent to a C++ gui (windows exe) via a callback function in the DLL. Then I'll be able to do this: test.py import

Re: (3.2) Overload print() using the C API?

2012-04-27 Thread Stefan Behnel
Peter Faulks, 27.04.2012 10:36: On 27/04/2012 5:15 PM, Stefan Behnel wrote: Peter Faulks, 26.04.2012 19:57: I want to extend an embedded interpreter so that calls to print() are automagically sent to a C++ gui (windows exe) via a callback function in the DLL. Then I'll be able to do this:

Re: why () is () and [] is [] work in other way?

2012-04-27 Thread Adam Skutt
On Apr 26, 10:56 pm, OKB (not okblacke) brennospamb...@nobrenspambarn.net wrote: Adam Skutt wrote: If I write a function that does a value comparison, then it should do value comparison on _every type that can be passed to it_, regardless of whether the type is a primitive or an object,

Re: Half-baked idea: list comprehensions with while

2012-04-27 Thread Miles Rout
On 27/04/2012 5:57 a.m., Kiuhnm wrote: On 4/26/2012 19:48, Paul Rubin wrote: Roy Smithr...@panix.com writes: x = [a for a in iterable while a] from itertools import takewhile x = takewhile(bool, a) I see that as a 'temporary' solution, otherwise we wouldn't need 'if' inside of list

Re: Half-baked idea: list comprehensions with while

2012-04-27 Thread Chris Angelico
On Fri, Apr 27, 2012 at 7:49 PM, Miles Rout miles.r...@gmail.com wrote: We have if inside list comprehensions? I didn't know that, could you provide an example? You mean like: [x*2+1 for x in range(10) if x%3] ? ChrisA -- http://mail.python.org/mailman/listinfo/python-list

Re: Half-baked idea: list comprehensions with while

2012-04-27 Thread Kiuhnm
On 4/27/2012 11:49, Miles Rout wrote: On 27/04/2012 5:57 a.m., Kiuhnm wrote: On 4/26/2012 19:48, Paul Rubin wrote: Roy Smithr...@panix.com writes: x = [a for a in iterable while a] from itertools import takewhile x = takewhile(bool, a) I see that as a 'temporary' solution, otherwise we

Re: why () is () and [] is [] work in other way?

2012-04-27 Thread Steven D'Aprano
On Thu, 26 Apr 2012 18:02:31 +0200, Kiuhnm wrote: On 4/26/2012 16:00, Adam Skutt wrote: C# and Python do have a misfeature: '==' is identity comparison only if operator== / __eq__ is not overloaded. Identity comparison and value comparison are disjoint operations, so it's entirely

Re: Half-baked idea: list comprehensions with while

2012-04-27 Thread Tim Wintle
On Fri, 2012-04-27 at 19:57 +1000, Chris Angelico wrote: On Fri, Apr 27, 2012 at 7:49 PM, Miles Rout miles.r...@gmail.com wrote: We have if inside list comprehensions? I didn't know that, could you provide an example? You mean like: [x*2+1 for x in range(10) if x%3] Or like: print [

Re: why () is () and [] is [] work in other way?

2012-04-27 Thread Robert Kern
On 4/27/12 12:07 AM, Paul Rubin wrote: Nobodynob...@nowhere.com writes: All practical languages have some implementation-defined behaviour, often far more problematic than Python's. The usual reason for accepting implementation-defined behavior is to enable low-level efficiency hacks written

Re: why () is () and [] is [] work in other way?

2012-04-27 Thread Steven D'Aprano
On Thu, 26 Apr 2012 11:31:39 -0700, John Nagle wrote: I would suggest that is raise ValueError for the ambiguous cases. If both operands are immutable, is should raise ValueError. That's the case where the internal representation of immutables shows through. You've already made this

syntax for code blocks

2012-04-27 Thread Kiuhnm
I'd like to change the syntax of my module 'codeblocks' to make it more pythonic. Current Syntax: with res func(arg1) 'x, y': print(x, y) with res func(arg1) block_name 'x, y': print(x, y) New Syntax: with res == func(arg1) .taking_block (x, y):

Re: Half-baked idea: list comprehensions with while

2012-04-27 Thread Chris Angelico
On Fri, Apr 27, 2012 at 8:37 PM, Tim Wintle tim.win...@teamrubber.com wrote: Or like: print [ 0 if b%2==1 else 1 for b in range(10)] [1, 0, 1, 0, 1, 0, 1, 0, 1, 0] That's nothing to do with the list comp, that's just the expression-if syntax that you can use anywhere. ChrisA --

Re: why () is () and [] is [] work in other way?

2012-04-27 Thread Kiuhnm
On 4/27/2012 13:09, Steven D'Aprano wrote: On Thu, 26 Apr 2012 18:02:31 +0200, Kiuhnm wrote: On 4/26/2012 16:00, Adam Skutt wrote: C# and Python do have a misfeature: '==' is identity comparison only if operator== / __eq__ is not overloaded. Identity comparison and value comparison are

Re: RuntimeWarning: Unable to load template engine entry point

2012-04-27 Thread sajuptpm
Issue get solved by updating following packages $ easy_install -U DecoratorTools $ easy_install -U turbojson -- http://mail.python.org/mailman/listinfo/python-list

Re: why () is () and [] is [] work in other way?

2012-04-27 Thread Chris Angelico
On Fri, Apr 27, 2012 at 10:07 PM, Kiuhnm kiuhnm03.4t.yahoo...@mail.python.org wrote: Conceptually, NaN is the class of all elements which are not numbers, therefore NaN = NaN. The conceptually correct way would be to check for 'NaN' explicitly. Conceptually, single-digit-numbers is the class

Re: Half-baked idea: list comprehensions with while

2012-04-27 Thread John O'Hagan
On Fri, 27 Apr 2012 19:57:31 +1000 Chris Angelico ros...@gmail.com wrote: On Fri, Apr 27, 2012 at 7:49 PM, Miles Rout miles.r...@gmail.com wrote: We have if inside list comprehensions? I didn't know that, could you provide an example? You mean like: [x*2+1 for x in range(10) if x%3]

Re: why () is () and [] is [] work in other way?

2012-04-27 Thread Kiuhnm
On 4/27/2012 14:07, Kiuhnm wrote: On 4/27/2012 13:09, Steven D'Aprano wrote: On Thu, 26 Apr 2012 18:02:31 +0200, Kiuhnm wrote: On 4/26/2012 16:00, Adam Skutt wrote: C# and Python do have a misfeature: '==' is identity comparison only if operator== / __eq__ is not overloaded. Identity

Re: Half-baked idea: list comprehensions with while

2012-04-27 Thread Chris Angelico
On Fri, Apr 27, 2012 at 10:17 PM, John O'Hagan resea...@johnohagan.com wrote: results = [x = expensive_call(i) for i in iterable if condition(x)] Nest it: results = [x for x in (expensive_call(i) for i in iterable) if condition(x)] ChrisA -- http://mail.python.org/mailman/listinfo/python-list

Re: Half-baked idea: list comprehensions with while

2012-04-27 Thread Tim Chase
On 04/27/12 07:23, Chris Angelico wrote: On Fri, Apr 27, 2012 at 10:17 PM, John O'Haganresea...@johnohagan.com wrote: results = [x = expensive_call(i) for i in iterable if condition(x)] Nest it: results = [x for x in (expensive_call(i) for i in iterable) if condition(x)] While it's what I

Re: why () is () and [] is [] work in other way?

2012-04-27 Thread Steven D'Aprano
On Fri, 27 Apr 2012 14:17:48 +0200, Kiuhnm wrote: Define your terms: what do you mean by equal? a and b are equal iff Nope. What I meant is that we can talk of equality whenever... a = a a = b = b = a a = b and b = c = a = c If some of this properties are violated, we're talking of

Re: syntax for code blocks

2012-04-27 Thread Steven D'Aprano
On Fri, 27 Apr 2012 13:24:35 +0200, Kiuhnm wrote: I'd like to change the syntax of my module 'codeblocks' to make it more pythonic. Current Syntax: with res func(arg1) 'x, y': print(x, y) with res func(arg1) block_name 'x, y': print(x, y) I'm sorry,

Re: why () is () and [] is [] work in other way?

2012-04-27 Thread Kiuhnm
On 4/27/2012 1:57, Adam Skutt wrote: On Apr 26, 6:34 pm, Kiuhnmkiuhnm03.4t.yahoo.it wrote: On 4/26/2012 20:54, Adam Skutt wrote: On Apr 26, 12:02 pm, Kiuhnmkiuhnm03.4t.yahoo.itwrote: On 4/26/2012 16:00, Adam Skutt wrote: On Apr 26, 9:37 am, Kiuhnmkiuhnm03.4t.yahoo.it wrote: The

Re: syntax for code blocks

2012-04-27 Thread Kiuhnm
On 4/27/2012 16:09, Steven D'Aprano wrote: On Fri, 27 Apr 2012 13:24:35 +0200, Kiuhnm wrote: I'd like to change the syntax of my module 'codeblocks' to make it more pythonic. Current Syntax: with res func(arg1) 'x, y': print(x, y) with res func(arg1) block_name

Re: why () is () and [] is [] work in other way?

2012-04-27 Thread Kiuhnm
On 4/27/2012 16:07, Steven D'Aprano wrote: On Fri, 27 Apr 2012 14:17:48 +0200, Kiuhnm wrote: Define your terms: what do you mean by equal? a and b are equal iff Nope. What I meant is that we can talk of equality whenever... a = a a = b = b = a a = b and b = c = a = c If some of this

Re: why () is () and [] is [] work in other way?

2012-04-27 Thread Adam Skutt
On Apr 27, 8:07 am, Kiuhnm kiuhnm03.4t.yahoo.it wrote: Useful... maybe, conceptually sound... no. Conceptually, NaN is the class of all elements which are not numbers, therefore NaN = NaN. NaN isn't really the class of all elements which aren't numbers. NaN is the result of a few specific

Re: syntax for code blocks

2012-04-27 Thread Steven D'Aprano
On Fri, 27 Apr 2012 17:03:19 +0200, Kiuhnm wrote: On 4/27/2012 16:09, Steven D'Aprano wrote: On Fri, 27 Apr 2012 13:24:35 +0200, Kiuhnm wrote: I'd like to change the syntax of my module 'codeblocks' to make it more pythonic. Current Syntax: with res func(arg1) 'x, y':

Re: why () is () and [] is [] work in other way?

2012-04-27 Thread Ian Kelly
On Fri, Apr 27, 2012 at 9:39 AM, Adam Skutt ask...@gmail.com wrote: On Apr 27, 8:07 am, Kiuhnm kiuhnm03.4t.yahoo.it wrote: Useful... maybe, conceptually sound... no. Conceptually, NaN is the class of all elements which are not numbers, therefore NaN = NaN. NaN isn't really the class of all

Re: syntax for code blocks

2012-04-27 Thread Ian Kelly
On Fri, Apr 27, 2012 at 10:07 AM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: How about you give an actual working example of what you mean by a code block and how you use it? He wrote a full blog post about it last week:

Borg identity [was Re: why () is () and [] is [] work in other way?]

2012-04-27 Thread Steven D'Aprano
On Thu, 26 Apr 2012 04:42:36 -0700, Adam Skutt wrote: You're going to have to explain the value of an ID that's not 1:1 with an object's identity, for at least the object's lifecycle, for a programmer. If you can't come up with a useful case, then you haven't said anything of merit. I gave

Re: why () is () and [] is [] work in other way?

2012-04-27 Thread mwilson
Adam Skutt wrote: [ ... ] In the real world, if we were doing the math with pen and paper, we'd stop as soon as we hit such an error. Equality is simply not defined for the operations that can produce NaN, because we don't know to perform those computations. So no, it doesn't conceptually

Direct vs indirect [was Re: why () is () and [] is [] work in other way?]

2012-04-27 Thread Steven D'Aprano
On Thu, 26 Apr 2012 04:42:36 -0700, Adam Skutt wrote: On Apr 26, 5:10 am, Steven D'Aprano steve +comp.lang.pyt...@pearwood.info wrote: But I was actually referring to something more fundamental than that. The statement a is b is a *direct* statement of identity. John is my father. id(a) ==

HTML Code - Line Number

2012-04-27 Thread SMac2347
Hello, For scrapping purposes, I am having a bit of trouble writing a block of code to define, and find, the relative position (line number) of a string of HTML code. I can pull out one string that I want, and then there is always a line of code, directly beneath the one I can pull out, that

Python id() does not return an address [was Re: why () is () and [] is [] work in other way?]

2012-04-27 Thread Steven D'Aprano
On Thu, 26 Apr 2012 04:42:36 -0700, Adam Skutt wrote: On Apr 26, 5:10 am, Steven D'Aprano steve +comp.lang.pyt...@pearwood.info wrote: Solution to *what problem*? This confusion that many people have over what 'is' does, including yourself. I have no confusion over what is does. The is

Re: why () is () and [] is [] work in other way?

2012-04-27 Thread Adam Skutt
On Apr 27, 11:01 am, Kiuhnm kiuhnm03.4t.yahoo.it wrote: On 4/27/2012 1:57, Adam Skutt wrote: On Apr 26, 6:34 pm, Kiuhnmkiuhnm03.4t.yahoo.it  wrote: If you understand that your 'a' is not really an object but a reference to it, everything becomes clear and you see that '==' always do the

Re: Python id() does not return an address [was Re: why () is () and [] is [] work in other way?]

2012-04-27 Thread Temia Eszteri
Steven, your posts are leaking out of their respective thread(s). Is this intentional? ~Temia -- When on earth, do as the earthlings do. -- http://mail.python.org/mailman/listinfo/python-list

Re: (3.2) Overload print() using the C API?

2012-04-27 Thread Terry Reedy
On 4/27/2012 4:55 AM, Stefan Behnel wrote: I want the script itself to update a window in the host application (via the extension) every time the script calls print(). Then replace sys.stdout (and maybe also sys.stderr) by another object that does what you want whenever its write() method is

Re: Borg identity [was Re: why () is () and [] is [] work in other way?]

2012-04-27 Thread Adam Skutt
On Apr 27, 12:56 pm, Steven D'Aprano steve +comp.lang.pyt...@pearwood.info wrote: On Thu, 26 Apr 2012 04:42:36 -0700, Adam Skutt wrote: You're going to have to explain the value of an ID that's not 1:1 with an object's identity, for at least the object's lifecycle, for a programmer.  If you

Re: Borg identity [was Re: why () is () and [] is [] work in other way?]

2012-04-27 Thread Chris Angelico
On Sat, Apr 28, 2012 at 3:33 AM, Adam Skutt ask...@gmail.com wrote: I think you misunderstood me.  Define a Borg class where somehow identity is the same for all instances.  Inherit from that class and add per-instance members.  Now, identity can't be the same for all instances.  As a result,

Variables and values [was Re: why () is () and [] is [] work in other way?]

2012-04-27 Thread Steven D'Aprano
On Fri, 27 Apr 2012 10:15:32 -0700, Adam Skutt wrote: If I write a program in Python that treats variables as if they were values, it will be incorrect. I'm sorry, it is unclear to me what distinction you are making between variables and values. Can you give simple examples of both incorrect

Re: Python id() does not return an address [was Re: why () is () and [] is [] work in other way?]

2012-04-27 Thread Adam Skutt
On Apr 27, 1:12 pm, Steven D'Aprano steve +comp.lang.pyt...@pearwood.info wrote: On Thu, 26 Apr 2012 04:42:36 -0700, Adam Skutt wrote: On Apr 26, 5:10 am, Steven D'Aprano steve +comp.lang.pyt...@pearwood.info wrote: Solution to *what problem*? This confusion that many people have over

Re: Borg identity [was Re: why () is () and [] is [] work in other way?]

2012-04-27 Thread Ian Kelly
On Fri, Apr 27, 2012 at 11:33 AM, Adam Skutt ask...@gmail.com wrote: On Apr 27, 12:56 pm, Steven D'Aprano steve +comp.lang.pyt...@pearwood.info wrote: On Thu, 26 Apr 2012 04:42:36 -0700, Adam Skutt wrote: You're going to have to explain the value of an ID that's not 1:1 with an object's

setting an array element with sequence problem problem

2012-04-27 Thread Debashish Saha
from __future__ import division from numpy import* import numpy as np import matplotlib.pyplot as plt from scipy.special import jv from scipy.special import yn h_cross=1 m=1 E=np.linspace(0.1,10,100) V0=-100 R=2 K=(2*E)**0.5 K_P=(2*(E-V0))**0.5 '''r=np.linspace(-10,10,1000) def V(r): if

Re: Direct vs indirect [was Re: why () is () and [] is [] work in other way?]

2012-04-27 Thread Adam Skutt
On Apr 27, 1:06 pm, Steven D'Aprano steve +comp.lang.pyt...@pearwood.info wrote: On Thu, 26 Apr 2012 04:42:36 -0700, Adam Skutt wrote: On Apr 26, 5:10 am, Steven D'Aprano steve +comp.lang.pyt...@pearwood.info wrote: But I was actually referring to something more fundamental than that. The

Re: Borg identity [was Re: why () is () and [] is [] work in other way?]

2012-04-27 Thread Ian Kelly
On Fri, Apr 27, 2012 at 11:38 AM, Chris Angelico ros...@gmail.com wrote: On Sat, Apr 28, 2012 at 3:33 AM, Adam Skutt ask...@gmail.com wrote: I think you misunderstood me.  Define a Borg class where somehow identity is the same for all instances.  Inherit from that class and add per-instance

Re: Python id() does not return an address [was Re: why () is () and [] is [] work in other way?]

2012-04-27 Thread Chris Angelico
On Sat, Apr 28, 2012 at 3:51 AM, Adam Skutt ask...@gmail.com wrote: Yes, there is a way.  You add a function deref() to the language.  In CPython, that simply treats the passed value as a memory address and treats it as an object, perhaps with an optional check.  In Jython, it'd access a

RE: why () is () and [] is [] work in other way?

2012-04-27 Thread Prasad, Ramit
I have spent some time searching for a bug in my code, it was due to different work of is with () and []: () is () True [] is [] False (Python 2.7.2+ (default, Oct 4 2011, 20:03:08) [GCC 4.6.1] ) Is this what it should be or maybe yielding unified result is better? D.

Re: Borg identity [was Re: why () is () and [] is [] work in other way?]

2012-04-27 Thread Steven D'Aprano
On Fri, 27 Apr 2012 10:33:34 -0700, Adam Skutt wrote: Why should the caller care whether they are dealing with a singleton object or an unspecified number of Borg objects all sharing state? A clever interpreter could make many Borg instances appear to be a singleton. A really clever one could

RE: HTML Code - Line Number

2012-04-27 Thread Prasad, Ramit
Hello, For scrapping purposes, I am having a bit of trouble writing a block of code to define, and find, the relative position (line number) of a string of HTML code. I can pull out one string that I want, and then there is always a line of code, directly beneath the one I can pull out,

CPython thread starvation

2012-04-27 Thread John Nagle
I have a multi-threaded CPython program, which has up to four threads. One thread is simply a wait loop monitoring the other three and waiting for them to finish, so it can give them more work to do. When the work threads, which read web pages and then parse them, are compute-bound, I've

Re: hex to bin 16 bit word

2012-04-27 Thread Paul Rubin
python w.g.sned...@gmail.com writes: What to decode hex '0xC0A8' and return signed short int. Is this right? n = int('0xC0A8', 16) if n = 0x: n -= 0x1 -- http://mail.python.org/mailman/listinfo/python-list

Re: hex to bin 16 bit word

2012-04-27 Thread Steven D'Aprano
On Fri, 27 Apr 2012 11:56:45 -0700, Paul Rubin wrote: python w.g.sned...@gmail.com writes: What to decode hex '0xC0A8' and return signed short int. Is this right? n = int('0xC0A8', 16) if n = 0x: n -= 0x1 No. struct.unpack('h',b'\xC0\xA8') (-16216,) n =

Re: setting an array element with sequence problem problem

2012-04-27 Thread Robert Kern
On 4/27/12 7:18 PM, Debashish Saha wrote: You will want to ask numpy questions on the numpy mailing list. http://www.scipy.org/Mailing_Lists When you do, I recommend stating a clear question in addition to the code and the traceback (although those are very much appreciated). But just to

Re: hex to bin 16 bit word

2012-04-27 Thread Grant Edwards
On 2012-04-27, Paul Rubin no.email@nospam.invalid wrote: python w.g.sned...@gmail.com writes: What to decode hex '0xC0A8' and return signed short int. Is this right? n = int('0xC0A8', 16) if n = 0x: n -= 0x1 Yes, as long as the input value doesn't exceed 0x1.

Re: hex to bin 16 bit word

2012-04-27 Thread Paul Rubin
Steven D'Aprano steve+comp.lang.pyt...@pearwood.info writes: Is this right? n = int('0xC0A8', 16) if n = 0x: n -= 0x1 No. Oops, I meant n = 0x7fff. Checking the sign bit. Grant Edwards invalid@invalid.invalid writes: Yes, as long as the input value doesn't

Re: hex to bin 16 bit word

2012-04-27 Thread Ian Kelly
On Fri, Apr 27, 2012 at 12:56 PM, Paul Rubin no.email@nospam.invalid wrote: python w.g.sned...@gmail.com writes: What to decode hex '0xC0A8'  and return signed short int. Is this right?    n = int('0xC0A8', 16)    if n = 0x:       n -= 0x1 No. n = int('0xC0A8', 16) if n = 0x8000:

Re: hex to bin 16 bit word

2012-04-27 Thread MRAB
On 27/04/2012 20:32, Ian Kelly wrote: On Fri, Apr 27, 2012 at 12:56 PM, Paul Rubinno.email@nospam.invalid wrote: pythonw.g.sned...@gmail.com writes: What to decode hex '0xC0A8' and return signed short int. Is this right? n = int('0xC0A8', 16) if n= 0x: n -=

Re: hex to bin 16 bit word

2012-04-27 Thread Grant Edwards
On 2012-04-27, Grant Edwards invalid@invalid.invalid wrote: On 2012-04-27, Paul Rubin no.email@nospam.invalid wrote: python w.g.sned...@gmail.com writes: What to decode hex '0xC0A8' and return signed short int. Is this right? n = int('0xC0A8', 16) if n = 0x: n -=

Re: hex to bin 16 bit word

2012-04-27 Thread Grant Edwards
On 2012-04-27, Grant Edwards invalid@invalid.invalid wrote: On 2012-04-27, Grant Edwards invalid@invalid.invalid wrote: On 2012-04-27, Paul Rubin no.email@nospam.invalid wrote: python w.g.sned...@gmail.com writes: What to decode hex '0xC0A8' and return signed short int. Is this right?

Re: HTML Code - Line Number

2012-04-27 Thread Jon Clements
SMac2347 at comcast.net writes: Hello, [snip] Any thoughts as to how to define a function to do this, or do this some other way? All insight is much appreciated! Thanks. Did you not see my reply to your previous thread? And why do you want the line number? Jon. --

Re: (3.2) Overload print() using the C API?

2012-04-27 Thread Peter Faulks
On 27/04/2012 6:55 PM, Stefan Behnel wrote: Peter Faulks, 27.04.2012 10:36: On 27/04/2012 5:15 PM, Stefan Behnel wrote: Peter Faulks, 26.04.2012 19:57: I want to extend an embedded interpreter so that calls to print() are automagically sent to a C++ gui (windows exe) via a callback function

Re: CPython thread starvation

2012-04-27 Thread Kiuhnm
On 4/27/2012 20:54, John Nagle wrote: I have a multi-threaded CPython program, which has up to four threads. One thread is simply a wait loop monitoring the other three and waiting for them to finish, so it can give them more work to do. When the work threads, which read web pages and then parse

Re: CPython thread starvation

2012-04-27 Thread Paul Rubin
John Nagle na...@animats.com writes: I know that the CPython thread dispatcher sucks, but I didn't realize it sucked that bad. Is there a preference for running threads at the head of the list (like UNIX, circa 1979) or something like that? I think it's left up to the OS thread scheduler,

Re: Borg identity [was Re: why () is () and [] is [] work in other way?]

2012-04-27 Thread Adam Skutt
On Apr 27, 2:40 pm, Steven D'Aprano steve +comp.lang.pyt...@pearwood.info wrote: On Fri, 27 Apr 2012 10:33:34 -0700, Adam Skutt wrote: Why should the caller care whether they are dealing with a singleton object or an unspecified number of Borg objects all sharing state? A clever interpreter

ControlDesk, Python, ActiveX, TableEditor

2012-04-27 Thread Chuck
I am trying to hook into the TableEditor on Controldesk using Python. Unfortunately there are no good examples of how to write the code anywhere I have looked. Does anyone know where to look? OR does anyone have code? Thanks Chuck -- http://mail.python.org/mailman/listinfo/python-list

Re: CPython thread starvation

2012-04-27 Thread MRAB
On 27/04/2012 23:30, Dennis Lee Bieber wrote: Oh, continuation thought... If the workers are calling into C-language operations, unless those operations release the GIL, it doesn't matter what the OS or Python thread switch timings are. The OS may interrupt the thread (running

Re: CPython thread starvation

2012-04-27 Thread Adam Skutt
On Apr 27, 2:54 pm, John Nagle na...@animats.com wrote:      I have a multi-threaded CPython program, which has up to four threads.  One thread is simply a wait loop monitoring the other three and waiting for them to finish, so it can give them more work to do.  When the work threads, which

Re: Borg identity

2012-04-27 Thread Ben Finney
Adam Skutt ask...@gmail.com writes: On Apr 27, 12:56 pm, Steven D'Aprano steve +comp.lang.pyt...@pearwood.info wrote: On Thu, 26 Apr 2012 04:42:36 -0700, Adam Skutt wrote: Steven D'Aprano wrote: The Borg design pattern, for example, would be an excellent candidate for ID:identity

Re: CPython thread starvation

2012-04-27 Thread John Nagle
On 4/27/2012 6:25 PM, Adam Skutt wrote: On Apr 27, 2:54 pm, John Naglena...@animats.com wrote: I have a multi-threaded CPython program, which has up to four threads. One thread is simply a wait loop monitoring the other three and waiting for them to finish, so it can give them more work

Re: CPython thread starvation

2012-04-27 Thread Chris Angelico
On Sat, Apr 28, 2012 at 1:35 PM, John Nagle na...@animats.com wrote: On CentOS, getaddrinfo() at the glibc level doesn't always cache locally (ref https://bugzilla.redhat.com/show_bug.cgi?id=576801).  Python doesn't cache either. How do you manage your local cache? The Python getaddrinfo

Re: CPython thread starvation

2012-04-27 Thread Paul Rubin
John Nagle na...@animats.com writes: The code that stored them looked them up with getaddrinfo(), and did this while a lock was set. Don't do that!! Added a local cache in the program to prevent this. Performance much improved. Better to release the lock while the getaddrinfo is

Re: CPython thread starvation

2012-04-27 Thread John Nagle
On 4/27/2012 9:20 PM, Paul Rubin wrote: John Naglena...@animats.com writes: The code that stored them looked them up with getaddrinfo(), and did this while a lock was set. Don't do that!! Added a local cache in the program to prevent this. Performance much improved. Better to

Re: CPython thread starvation

2012-04-27 Thread Paul Rubin
John Nagle na...@animats.com writes: I may do that to prevent the stall. But the real problem was all those DNS requests. Parallizing them wouldn't help much when it took hours to grind through them all. True dat. But building a DNS cache into the application seems like a kludge. Unless

Re: CPython thread starvation

2012-04-27 Thread John Nagle
On 4/27/2012 9:55 PM, Paul Rubin wrote: John Naglena...@animats.com writes: I may do that to prevent the stall. But the real problem was all those DNS requests. Parallizing them wouldn't help much when it took hours to grind through them all. True dat. But building a DNS cache into

[issue14579] CVE-2012-2135: Vulnerability in the utf-16 decoder after error handling

2012-04-27 Thread Georg Brandl
Changes by Georg Brandl ge...@python.org: -- nosy: +georg.brandl ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14579 ___ ___ Python-bugs-list

[issue14339] Optimizing bin, oct and hex

2012-04-27 Thread Martin v . Löwis
Martin v. Löwis mar...@v.loewis.de added the comment: Serhiy: what's the status of your contributor form? Note that you can also fax it, or scan it and send it by email. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14339

[issue14676] DeprecationWarning missing in default warning filters documentation

2012-04-27 Thread Ezio Melotti
Changes by Ezio Melotti ezio.melo...@gmail.com: -- keywords: +easy nosy: +ezio.melotti stage: - patch review type: - enhancement ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14676 ___

[issue1521950] shlex.split() does not tokenize like the shell

2012-04-27 Thread Ezio Melotti
Changes by Ezio Melotti ezio.melo...@gmail.com: -- nosy: +ezio.melotti ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1521950 ___ ___

[issue14656] Add a macro for unreachable code

2012-04-27 Thread Ezio Melotti
Changes by Ezio Melotti ezio.melo...@gmail.com: -- nosy: +ezio.melotti ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14656 ___ ___

[issue13934] sqlite3 test typo

2012-04-27 Thread Ezio Melotti
Changes by Ezio Melotti ezio.melo...@gmail.com: -- nosy: +ezio.melotti ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13934 ___ ___

[issue14673] add sys.implementation

2012-04-27 Thread Martin v . Löwis
Martin v. Löwis mar...@v.loewis.de added the comment: When I added sys.subversion, people requested that it shall contain the CPython string. When sys._mercurial was introduced, it copied that. So there are plenty of ways already to figure out that it is CPython which you are using.

[issue8767] Configure: Cannot disable unicode

2012-04-27 Thread Stefano Taschini
Stefano Taschini tasch...@ieee.org added the comment: Here's the patch. It has four goals: 1. Allow ./configure --disable-unicode to work; 2. Have the naked interpreter running with no unicode support; 3. Be able to compile most of the stdlib; 4. Be able to run the test suite.

[issue2387] cStringIO and unicode

2012-04-27 Thread Florent Xicluna
Florent Xicluna florent.xicl...@gmail.com added the comment: It seems the documentation is not enough accurate. Unlike the StringIO module, this module is not able to accept Unicode strings that cannot be encoded as plain ASCII strings. I understand that u'foo' can be encoded as plan ASCII,

[issue14673] add sys.implementation

2012-04-27 Thread Eric Snow
Eric Snow ericsnowcurren...@gmail.com added the comment: An updated patch using a dict. (FYI, I have the PEP up on python-ideas.) -- Added file: http://bugs.python.org/file25378/sys_implementation_2.diff ___ Python tracker rep...@bugs.python.org

[issue14610] configure script hangs on pthread verification and PTHREAD_SCOPE_SYSTEM verification on Ubuntu

2012-04-27 Thread Charles-François Natali
Charles-François Natali neolo...@free.fr added the comment: Yes, this code is hanging in my system. I'm posting the strace output. If there's any other information that may be helpful I'll happily provide it. Well, in that case it's a bug in your pthread implementation: returning from main()

[issue14681] Problem in installation of version 2.3.5 on mac OS X 10.5.8

2012-04-27 Thread rampythonnewbie
New submission from rampythonnewbie ramumca7...@gmail.com: Hello, I am working on an application that runs only on Python version 2.3.5. Presently i am using mac os x 10.5.8. It came with pre-installed python 2.5.1. Now, when i am running that application with existing version, it is showing

[issue11618] Locks broken wrt timeouts on Windows

2012-04-27 Thread Kristján Valur Jónsson
Kristján Valur Jónsson krist...@ccpgames.com added the comment: Antoine: of course, sorry for rushing you. Martin, This is an XP patch. The vista option is put in there as a compile time option, and disabled by hand. I'm not adding any apis that weren't already in use since the new gil

[issue13210] Support Visual Studio 2010

2012-04-27 Thread Richard Oudkerk
Richard Oudkerk shibt...@gmail.com added the comment: The problems with error numbers seem to be caused by the addition of a new section in errno.h: /* POSIX SUPPLEMENT */ #define EADDRINUSE 100 #define EADDRNOTAVAIL 101 ... #define ETXTBSY 139 #define EWOULDBLOCK 140 Of

[issue14339] Optimizing bin, oct and hex

2012-04-27 Thread STINNER Victor
STINNER Victor victor.stin...@gmail.com added the comment: You may call assert(_PyUnicode_CheckConsistency(v, 1)) to ensure that the newly created string is consistent (see the function for the details). Done in the following changeset: changeset: 76560:3bdcf0cab164 parent:

[issue2387] cStringIO and unicode

2012-04-27 Thread Antoine Pitrou
Antoine Pitrou pit...@free.fr added the comment: This was fixed in 2.7.3 actually (27ae7d4e1983): Python 2.7.3+ (2.7:8b8b580e3fd3, Apr 25 2012, 17:24:51) [GCC 4.5.2] on linux2 Type help, copyright, credits or license for more information. from cStringIO import StringIO

[issue8767] Configure: Cannot disable unicode

2012-04-27 Thread Antoine Pitrou
Changes by Antoine Pitrou pit...@free.fr: -- nosy: +loewis ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8767 ___ ___ Python-bugs-list mailing

[issue13621] Unicode performance regression in python3.3 vs python3.2

2012-04-27 Thread STINNER Victor
STINNER Victor victor.stin...@gmail.com added the comment: Andrew+Dalke (*1000): -23.076923% /python -m timeit 'Andrew+Dalke' gives me very close results with Python 3.2 (wide mode) and 3.3. Somethings like 0.15 vs 0.151 microseconds. But using longer (ASCII) strings, Python 3.3 is 2.6x

[issue1065986] Fix pydoc crashing on unicode strings

2012-04-27 Thread Stefano Taschini
Stefano Taschini tasch...@ieee.org added the comment: Here's my patch, along the lines of the work-around I posted earlier. A few remarks: 1. The modifications in pydoc only touch the four console pagers and the html pager (html.page). 2. A module-wide default encoding is initialized

[issue14681] Problem in installation of version 2.3.5 on mac OS X 10.5.8

2012-04-27 Thread rampythonnewbie
rampythonnewbie ramumca7...@gmail.com added the comment: Hello, I am working on an application that runs only on Python version 2.3.5. Presently i am using mac os x 10.5.8. It came with pre-installed python 2.5.1. Now, when i am running that application with existing version, it is showing

  1   2   >