3 ms·
If you application is a server then out of memory error during a request means that the request failed but not that you should shut down the server. class not
by d0mine 17y ago
If you application is a server then out of memory error during a request means that the request failed but not that you should shut down the server.
class not found means that some functionality is unavailable but you could provide a workaround that might have some disadvantages compared to the absent version but would work. For example, in Python (ImportError plays role of class not found here)
try:
import cElementTree as ElementTree # fast C extension
except ImportError:
from elementtree import ElementTree # ~30 time slower
Don't panic ;)
- sbov 17y agoI'd rather have my application fail clearly and obviously than have it start to mysteriously run 30 times slower. At least in Java on the server side, most checked exceptions I run across fall under this umbrella. If they happen, something is really really wrong.
- d0mine 17y agoIf the code is in a library it is not your call to decide what is satisfactory performance and what requirements are. A user of your library could decide that running this code inside JVM (via Jython) is more important than using C extensions for speed. Real world example, an excellent tool -- Universal Feed Parser http://www.feedparser.org/ http://www.feedparser.org/ # If a real XML parser is available, feedparser will attempt to use it. feedparser has # been tested with the built-in SAX parser, PyXML, and libxml2. On platforms where the # Python distribution does not come with an XML parser (such as Mac OS X 10.2 and some # versions of FreeBSD), feedparser will quietly fall back on regex-based parsing. try: import xml.sax xml.sax.make_parser(PREFERRED_XML_PARSERS) # test for valid parsers from xml.sax.saxutils import escape as _xmlescape _XML_AVAILABLE = 1 except: _XML_AVAILABLE = 0 def _xmlescape(data,entities={}): data = data.replace('&', '&') data = data.replace('>', '>') data = data.replace('<', '<') for char, entity in entities: data = data.replace(char, entity) return data