Re: Bitshifts and "And" vs Floor-division and Modular

2012-09-06 Thread Mark Lawrence
On 07/09/2012 01:01, jimbo1qaz wrote: Is it faster to use bitshifts or floor division? And which is better, & or %? All divisors and mods are power of 2, so are binary operations faster? And are they considered bad style? Why don't you use the timeit module and find out for yourself? -- Chee

os.stat() distorts filenames that end with period (nt.stat())

2012-09-06 Thread ruck
(This with Python 2.7.2 on Windows 7) os.stat() won't recognize a filename ending in period. It will ignore trailing periods. If you ask it about file 'goo...' it will report on file 'goo' And if 'goo' doesn't exist, os.stat will complain. create file goo, then >>> os.stat('goo') nt.st

Re: Bitshifts and "And" vs Floor-division and Modular

2012-09-06 Thread jimbo1qaz
On Thursday, September 6, 2012 5:30:05 PM UTC-7, Mark Lawrence wrote: > On 07/09/2012 01:01, jimbo1qaz wrote: > > > Is it faster to use bitshifts or floor division? And which is better, & or > > %? > > > All divisors and mods are power of 2, so are binary operations faster? And > > are they con

Re: lxml can't output right unicode result

2012-09-06 Thread MRAB
On 07/09/2012 01:21, contro opinion wrote: i eidt a file and save it in gbk encode named test. my system is :debian,locale,en.utf-8;python2.6,locale,utf-8. 你 in terminal i input: xxd test 000: 3c68 746d 6c3e 0a3c 703e c4e3 3c2f 703e ... 010: 0a3c 2f68 746d 6c3e 0a

Re: Bitshifts and "And" vs Floor-division and Modular

2012-09-06 Thread Cameron Simpson
On 07Sep2012 01:30, Mark Lawrence wrote: | On 07/09/2012 01:01, jimbo1qaz wrote: | > Is it faster to use bitshifts or floor division? And which is better, & or %? | > All divisors and mods are power of 2, so are binary operations faster? And are they considered bad style? | | Why don't you use

Re: os.stat() distorts filenames that end with period (nt.stat())

2012-09-06 Thread Dave Angel
On 09/06/2012 08:55 PM, ruck wrote: > (This with Python 2.7.2 on Windows 7) > > os.stat() won't recognize a filename ending in period. > It will ignore trailing periods. > If you ask it about file 'goo...' it will report on file 'goo' > And if 'goo' doesn't exist, os.stat will complain. > > creat

Re: os.stat() distorts filenames that end with period (nt.stat())

2012-09-06 Thread Dwight Hutto
On Thu, Sep 6, 2012 at 8:55 PM, ruck wrote: > (This with Python 2.7.2 on Windows 7) > > os.stat() won't recognize a filename ending in period. > It will ignore trailing periods. > If you ask it about file 'goo...' it will report on file 'goo' > And if 'goo' doesn't exist, os.stat will complain. >

Re: Bitshifts and "And" vs Floor-division and Modular

2012-09-06 Thread jimbo1qaz
On Thursday, September 6, 2012 5:01:12 PM UTC-7, jimbo1qaz wrote: > Is it faster to use bitshifts or floor division? And which is better, & or %? > > All divisors and mods are power of 2, so are binary operations faster? And > are they considered bad style? OK, I decided to change my code. Which

Re: Bitshifts and "And" vs Floor-division and Modular

2012-09-06 Thread Dave Angel
On 09/06/2012 08:01 PM, jimbo1qaz wrote: > Is it faster to use bitshifts or floor division? Yes, and yes. Without doing any measurement, I'd expect that in CPython, it makes negligible performance difference for ordinary ints (under 2**31, more or less). Ordinary ints can be done with single inst

Re: Is there a way to configure IDLE to use spaces instead of tabs for indenting?

2012-09-06 Thread Alex
Terry Reedy wrote: [snip] > IDLE is not the interpreter. Fine, I meant shell. Thanks for fixing that for me. > The IDLE Shell is intended mainly for single-line inputs. Maybe it should be limited to that, then. That way stoopid noobs like me don't use it wrong and then use the wrong nomencla

Re: Bitshifts and "And" vs Floor-division and Modular

2012-09-06 Thread Dave Angel
On 09/06/2012 09:30 PM, jimbo1qaz wrote: > On Thursday, September 6, 2012 5:01:12 PM UTC-7, jimbo1qaz wrote: >> Is it faster to use bitshifts or floor division? And which is better, & or %? >> >> All divisors and mods are power of 2, so are binary operations faster? And >> are they considered bad

Re: os.stat() distorts filenames that end with period (nt.stat())

2012-09-06 Thread alex23
On Sep 7, 10:55 am, ruck wrote: > (This with Python 2.7.2 on Windows 7) > rename goo to "goo...", then, I'm unable to rename any file to have a '...' suffix, are you certain the file exists in the form you think after the rename? -- http://mail.python.org/mailman/listinfo/python-list

Re: os.stat() distorts filenames that end with period (nt.stat())

2012-09-06 Thread ruck
On Thursday, September 6, 2012 6:19:11 PM UTC-7, Dave Angel wrote: > On 09/06/2012 08:55 PM, ruck wrote: > > > (This with Python 2.7.2 on Windows 7) > > > > > > os.stat() won't recognize a filename ending in period. > > > It will ignore trailing periods. > > > If you ask it about file 'goo..

Re: Bitshifts and "And" vs Floor-division and Modular

2012-09-06 Thread Terry Reedy
On 9/6/2012 8:01 PM, jimbo1qaz wrote: Is it faster to use bitshifts or floor division? And which is better, & or %? All divisors and mods are power of 2, so are binary operations faster? And are they considered bad style? Yes, meaningless, yes, and no. I would do what seems sensible to you in t

Re: Bitshifts and "And" vs Floor-division and Modular

2012-09-06 Thread Steven D'Aprano
On Thu, 06 Sep 2012 17:01:12 -0700, jimbo1qaz wrote: > Is it faster to use bitshifts or floor division? Does it matter? If you ever find yourself writing an application where the difference between 0.0476 microseconds and 0.0473 microseconds matters to you, Python is probably the wrong langua

Re: os.stat() distorts filenames that end with period (nt.stat())

2012-09-06 Thread Terry Reedy
On 9/6/2012 8:55 PM, ruck wrote: (This with Python 2.7.2 on Windows 7) os.stat() won't recognize a filename ending in period. It will ignore trailing periods. If you ask it about file 'goo...' it will report on file 'goo' And if 'goo' doesn't exist, os.stat will complain. create file goo, then

Re: Parsing ISO date/time strings - where did the parser go?

2012-09-06 Thread Terry Reedy
On 9/6/2012 3:44 PM, Thomas Jollans wrote: On 09/06/2012 09:27 PM, John Nagle wrote: In Python 2.7: I want to parse standard ISO date/time strings such as 2012-09-09T18:00:00-07:00 into Python "datetime" objects. The "datetime" object offers an output method , datetimeobj.isoform

Re: Bitshifts and "And" vs Floor-division and Modular

2012-09-06 Thread Steven D'Aprano
On Thu, 06 Sep 2012 18:30:48 -0700, jimbo1qaz wrote: > OK, I decided to change my code. Which raises a similar question: Which > one is better for setting a bit of a byte: |= or +=, assuming each will > only be run once? Intuitively, I think |= Python (like most languages) doesn't have a "set thi

Re: os.stat() distorts filenames that end with period (nt.stat())

2012-09-06 Thread Steven D'Aprano
On Thu, 06 Sep 2012 17:55:02 -0700, ruck wrote: > (This with Python 2.7.2 on Windows 7) > > os.stat() won't recognize a filename ending in period. It will ignore > trailing periods. > If you ask it about file 'goo...' it will report on file 'goo' And if > 'goo' doesn't exist, os.stat will complai

Re: os.stat() distorts filenames that end with period (nt.stat())

2012-09-06 Thread ruck
On Thursday, September 6, 2012 6:49:43 PM UTC-7, alex23 wrote: > On Sep 7, 10:55 am, ruck wrote: > > > (This with Python 2.7.2 on Windows 7) > > > rename goo to "goo...", then, > > > > I'm unable to rename any file to have a '...' suffix, are you certain > > the file exists in the form you t

Re: os.stat() distorts filenames that end with period (nt.stat())

2012-09-06 Thread Ian Kelly
On Thu, Sep 6, 2012 at 6:55 PM, ruck wrote: > (This with Python 2.7.2 on Windows 7) > > os.stat() won't recognize a filename ending in period. > It will ignore trailing periods. > If you ask it about file 'goo...' it will report on file 'goo' > And if 'goo' doesn't exist, os.stat will complain. D

Re: Bitshifts and "And" vs Floor-division and Modular

2012-09-06 Thread rusi
On Sep 7, 5:01 am, jimbo1qaz wrote: > Is it faster to use bitshifts or floor division? And which is better, & or %? > All divisors and mods are power of 2, so are binary operations faster? And > are they considered bad style? On an 8086/8088 a MUL (multiply) instruction was of the order of 100 c

Re: Comparing strings from the back?

2012-09-06 Thread Steven D'Aprano
On Fri, 07 Sep 2012 00:39:33 +1000, Chris Angelico wrote: > On Thu, Sep 6, 2012 at 11:37 PM, Johannes Bauer > wrote: >> Not in my original post. If you read it again, you will clearly see >> that I was talking about purely random strings. And since you like to >> nitpick, I'll clarify further: I'

Re: Comparing strings from the back?

2012-09-06 Thread Steven D'Aprano
On Thu, 06 Sep 2012 06:07:38 -0400, Dave Angel wrote: > On 09/06/2012 04:33 AM, Steven D'Aprano wrote: >> >> >> I may have been overly-conservative earlier when I said that on average >> string equality has to compare half the characters. I thought I had >> remembered that from a computer science

Re: Bitshifts and "And" vs Floor-division and Modular

2012-09-06 Thread Paul Rubin
rusi writes: > On an 8086/8088 a MUL (multiply) instruction was of the order of 100 > clocks ... On most modern processors (after the pentium) the > difference has mostly vanished. I cant find a good data sheet to > quote though See http://www.agner.org/optimize/ : 4. Instruction tables: L

Re: os.stat() distorts filenames that end with period (nt.stat())

2012-09-06 Thread ruck
On Thursday, September 6, 2012 7:05:39 PM UTC-7, Terry Reedy wrote: > On 9/6/2012 8:55 PM, ruck wrote: > > > (This with Python 2.7.2 on Windows 7) > > > > > > os.stat() won't recognize a filename ending in period. > > > It will ignore trailing periods. > > > If you ask it about file 'goo...' i

<    1   2