##// END OF EJS Templates
Print a real "µs" instead of "us"...
Jan Schulz -
Show More
@@ -1,3 +1,4 b''
1 # -*- coding: utf-8 -*-
1 """Implementation of execution-related magic functions.
2 """Implementation of execution-related magic functions.
2 """
3 """
3 #-----------------------------------------------------------------------------
4 #-----------------------------------------------------------------------------
@@ -1076,26 +1077,20 b' def _format_time(timespan, precision=3):'
1076 """Formats the timespan in a human readable form"""
1077 """Formats the timespan in a human readable form"""
1077 import math
1078 import math
1078 # XXX: Unfortunately the unicode 'micro' symbol can cause problems in
1079 # XXX: Unfortunately the unicode 'micro' symbol can cause problems in
1079 # certain terminals. Until we figure out a robust way of
1080 # certain terminals.
1080 # auto-detecting if the terminal can deal with it, use plain 'us' for
1081 # microseconds. I am really NOT happy about disabling the proper
1082 # 'micro' prefix, but crashing is worse... If anyone knows what the
1083 # right solution for this is, I'm all ears...
1084 #
1085 # Note: using
1086 #
1087 # s = u'\xb5'
1088 # s.encode(sys.getdefaultencoding())
1089 #
1090 # is not sufficient, as I've seen terminals where that fails but
1091 # print s
1092 #
1093 # succeeds
1094 #
1095 # See bug: https://bugs.launchpad.net/ipython/+bug/348466
1081 # See bug: https://bugs.launchpad.net/ipython/+bug/348466
1096
1082
1097 #units = [u'h', u'min', u"s", u"ms",u'\xb5',"ns"]
1083 # This is trying to prevent crashes, so it's more secure than it needs to
1098 units = [u'h', u'min', u"s", u"ms",u'us',"ns"]
1084 # E.g. eclipse is able to print a µ, but has no sys.stdout.encoding set.
1085
1086
1087 units = [u'h', u'min', u"s", u"ms",u'us',"ns"] # the save value
1088 if sys.stdout.encoding:
1089 try:
1090 u'\xb5'.encode(sys.stdout.encoding)
1091 units = [u'h', u'min', u"s", u"ms",u'\xb5s',"ns"]
1092 except:
1093 pass
1099 scaling = [1./3600, 1./60, 1, 1e3, 1e6, 1e9]
1094 scaling = [1./3600, 1./60, 1, 1e3, 1e6, 1e9]
1100
1095
1101 if timespan > 0.0 and timespan < 60.0:
1096 if timespan > 0.0 and timespan < 60.0:
General Comments 0
You need to be logged in to leave comments. Login now