PageRenderTime 45ms CodeModel.GetById 18ms RepoModel.GetById 1ms app.codeStats 0ms

/pypy/module/sys/system.py

https://bitbucket.org/pypy/pypy/
Python | 66 lines | 63 code | 2 blank | 1 comment | 0 complexity | 09f286b41fdcd65ca2e590f5243bfd87 MD5 | raw file
Possible License(s): AGPL-3.0, BSD-3-Clause, Apache-2.0
  1. """Information about the current system."""
  2. from pypy.interpreter import gateway
  3. from rpython.rlib import rbigint, rfloat
  4. from rpython.rtyper.lltypesystem import rffi
  5. app = gateway.applevel("""
  6. "NOT_RPYTHON"
  7. from _structseq import structseqtype, structseqfield
  8. class float_info:
  9. __metaclass__ = structseqtype
  10. max = structseqfield(0)
  11. max_exp = structseqfield(1)
  12. max_10_exp = structseqfield(2)
  13. min = structseqfield(3)
  14. min_exp = structseqfield(4)
  15. min_10_exp = structseqfield(5)
  16. dig = structseqfield(6)
  17. mant_dig = structseqfield(7)
  18. epsilon = structseqfield(8)
  19. radix = structseqfield(9)
  20. rounds = structseqfield(10)
  21. class long_info:
  22. __metaclass__ = structseqtype
  23. bits_per_digit = structseqfield(0)
  24. sizeof_digit = structseqfield(1)
  25. """)
  26. def get_float_info(space):
  27. info_w = [
  28. space.wrap(rfloat.DBL_MAX),
  29. space.wrap(rfloat.DBL_MAX_EXP),
  30. space.wrap(rfloat.DBL_MAX_10_EXP),
  31. space.wrap(rfloat.DBL_MIN),
  32. space.wrap(rfloat.DBL_MIN_EXP),
  33. space.wrap(rfloat.DBL_MIN_10_EXP),
  34. space.wrap(rfloat.DBL_DIG),
  35. space.wrap(rfloat.DBL_MANT_DIG),
  36. space.wrap(rfloat.DBL_EPSILON),
  37. space.wrap(rfloat.FLT_RADIX),
  38. space.wrap(rfloat.FLT_ROUNDS),
  39. ]
  40. w_float_info = app.wget(space, "float_info")
  41. return space.call_function(w_float_info, space.newtuple(info_w))
  42. def get_long_info(space):
  43. bits_per_digit = rbigint.SHIFT
  44. sizeof_digit = rffi.sizeof(rbigint.STORE_TYPE)
  45. info_w = [
  46. space.wrap(bits_per_digit),
  47. space.wrap(sizeof_digit),
  48. ]
  49. w_long_info = app.wget(space, "long_info")
  50. return space.call_function(w_long_info, space.newtuple(info_w))
  51. def get_float_repr_style(space):
  52. return space.wrap("short")
  53. def getdlopenflags(space):
  54. return space.wrap(space.sys.dlopenflags)
  55. def setdlopenflags(space, w_flags):
  56. space.sys.dlopenflags = space.int_w(w_flags)