Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Warnings killing my performance

Reply
Thread Tools

Warnings killing my performance

 
 
Peter Otten
Guest
Posts: n/a
 
      02-08-2004
Kylotan wrote:

> Peter Otten <(E-Mail Removed)> wrote in message
> news:<c02ubl$qqt$07$(E-Mail Removed)-online.com>...
>
>> def disableWarnings():
>> def _theevilunwarner(*args):
>> pass
>> import warnings
>> warnings.warn = _theevilunwarner
>> warnings.warn_explicit = _theevilunwarner

>
> Heh, that's great. However, I don't think it really scales well to a
> full application, does it?


Well, you could disable warnings in critical parts only, but that wouldn't
play well with threads. Enter the not so evil unwarner:

def disableWarnings():
originalWarn = warnings.warn
disabled = sets.Set([
id(exceptions.OverflowWarning),
id(exceptions.FutureWarning)])

def _thenotsoevilunwarner(message, category=None, stacklevel=1):
if id(category) in disabled:
#print "DISMISS", message, category
pass
else:
#print "PROPAGATE", message, category
originalWarn(message, category, stacklevel)
warnings.warn = _thenotsoevilunwarner

It's still pretty fast (10.8 vs 27.1 usec on my machine), but the duplicate
test will slow down warnings that are actually propagated.

And if you are really ambitious, you could devise a patch to speed up warn()
in the library, maybe using a similar technique as shown above.

Peter

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Performance Tutorials Services - Boosting Performance by DisablingUnnecessary Services on Windows XP Home Edition Software Engineer Javascript 0 06-10-2011 02:18 AM
Killing The "Double Download" Box--Need Help Please Ducati@Darmah.net Firefox 2 05-05-2005 12:29 AM
use warnings; and use Warnings; give different results Ted Sung Perl Misc 1 08-30-2004 10:22 PM
killing a lingering VPN connection Eric Sabine Cisco 0 06-03-2004 03:04 PM
Web Form Performance Versus Single File Performance jm ASP .Net 1 12-12-2003 11:14 PM



Advertisments