1 2 3 4 5 6 7 8
|
>>>a=' The attribute sys.float_info.dig needs further explanation. If s is any string representing a decimal number with at most sys.float_info.dig significant digits, then converting s to a float and back again will recover a string representing the same decimal value: >>> import sys >>> sys.float_info.dig 15 >>> s = 3.14159265358979 # decimal string with 15 significant digits >>> format(float(s), .15g ) # convert to float and back -> same value 3.14159265358979 But for strings with more than sys.float_info.dig significant digits, this isn t always true: >>> s = 9876543211234567 # 16 significant digits is too many! >>> format(float(s), .16g ) # conversion changes value 9876543211234568 New in version 2.6.sys.float_repr_style¶ A string indicating how the repr() function behaves for floats. If the string has value short then for a finite float x, repr(x) aims to produce a short string with the property that float(repr(x)) == x. This is the usual behaviour in Python 2.7 and later. Otherwise, float_repr_style has value legacy and repr(x) behaves in the same way as it did in versions of Python prior to 2.7. New in version 2.7.sys.getcheckinterval()¶ Return the interpreter s "check interval"; see setcheckinterval(). New in version 2.3.sys.getdefaultencoding()¶ Return the name of the current default string encoding used by the Unicode implementation. New in version 2.0.sys.getdlopenflags()¶ Return the current value of the flags that are used for dlopen() calls. The flag constants are defined in the dl and DLFCN modules. Availability: Unix. New in version 2.2.sys.getfilesystemencoding()¶ Return the name of the encoding used to convert Unicode filenames into system file names, or None if the system default encoding is used. The result value depends on the operating system: * On Mac OS X, the encoding is utf-8 . * On Unix, the encoding is the user s preference according to the result of nl_langinfo(CODESET), or None if the nl_langinfo(CODESET) failed. * On Windows NT+, file names are Unicode natively, so no conversion is performed. getfilesystemencoding() still returns mbcs , as this is the encoding that applications should use when they explicitly want to convert Unicode strings to byte strings that are equivalent when used as file names. * On Windows 9x, the encoding is mbcs . New in version 2.3.sys.getrefcount(object)¶ Return the reference count of the object. The count returned is generally one higher than you might expect, because it includes the (temporary) reference as an argument to getrefcount().sys.getrecursionlimit()¶ Return the current value of the recursion limit, the maximum depth of the Python interpreter stack. This limit prevents infinite recursion from causing an overflow of the C stack and crashing Python. It can be set by setrecursionlimit().sys.getsizeof(object[, default])¶ Return the size of an object in bytes. The object can be any type of object. All built-in objects will return correct results, but this does not have to hold true for third-party extensions as it is implementation specific. If given, default will be returned if the object does not provide means to retrieve the size. Otherwise a TypeError will be raised. getsizeof() calls the object s __sizeof__ method and adds an additional garbage collector overhead if the object is managed by the garbage collector. New in version 2.6.sys._getframe([depth])¶ Return a frame object from the call stack. If optional integer depth is given, return the frame object that many calls below the top of the stack. If that is deeper than the call stack, ValueError is raised. The default for depth is zero, returning the frame at the top of the call stack. CPython implementation detail: This function should be used for internal and specialized purposes only. It is not guaranteed to exist in all implementations of Python.sys.getprofile()¶ Get the profiler function as set by setprofile(). New in version 2.6.sys.gettrace()¶ Get the trace function as set by settrace(). CPython implementation detail: The gettrace() function is intended only for implementing debuggers, profilers, coverage tools and the like. Its behavior is part of the implementation platform, rather than part of the language definition, and thus may not be available in all Python implementations.'
>>>b=zlib.compress(a)
>>>sys.getsizeof(a)
4468
>>> sys.getsizeof(b)
1780 |
Partager