0

I'm the one who trying to do code with python math library and I found something nonsense in math library.

def acos(__x: _SupportsFloatOrIndex) -> float: ...
def acosh(__x: _SupportsFloatOrIndex) -> float: ...
def asin(__x: _SupportsFloatOrIndex) -> float: ...
def asinh(__x: _SupportsFloatOrIndex) -> float: ...
def atan(__x: _SupportsFloatOrIndex) -> float: ...
def atan2(__y: _SupportsFloatOrIndex, __x: _SupportsFloatOrIndex) -> float: ...
def atanh(__x: _SupportsFloatOrIndex) -> float: ...

At math library, this kind of function is all around but I cannot find any other that can do the math. I think this happened because math library need to fast so they need to use C language. So people wrote ellipsis to wrap up the function. But it turns out that ellipsis did not do anything and I cannot find any module that import C's math library. I trying to solve this problem for three days but I cannot find any proper answer. So these are my questions.

  1. Ellipsis is used to some kind of markdown job so C's math code to go?
  2. Is there any code in python's math library that can call C's math code?
  3. As it turns out, In this kind of function that only do 'type hints'(I guess), can be replaced by any other statements like 'pass' or something else. Then why people use ellipsis? Is there any reason or they just make a promise to use ellipsis to type hints function?
김원중
  • 1
  • 1
  • 1
    You are looking at a [`.pyi`](https://stackoverflow.com/questions/41734836/what-does-i-represent-in-python-pyi-extension) file whose purpose is to provide type hints for a module otherwise written in C – DeepSpace Aug 13 '22 at 14:24
  • *"can be replaced by any other statements like 'pass' or something else. Then why people use ellipsis?"* If they would have used `pass`, would you have asked "why did they use `pass` and not elipsis? – DeepSpace Aug 13 '22 at 14:26
  • Some very essential modules written in C are compiled into the main Python executable (or DLL, depending on OS) and are not visible as separate PYD-files. – Michael Butscher Aug 13 '22 at 14:30
  • 1
    More particularly, `pass` is more often used in this situation when a block doesn't do anything at all. Ellipsis is often used for signifying that a block (usually a function) does do something, but that its source is somewhere else, like when using `typing.overload` or in a case like this representing C code. This isn't a hard rule though. – duckboycool Aug 13 '22 at 14:31
  • @DeepSpace Thanks! by the way, as I mentioned I just asked is there any other reason or 'just make a promise to use ellipsis to type hints function' is my question. – 김원중 Aug 15 '22 at 07:30
  • @duckboycool Thanks! I learned python solely by myself so a little bit hard to know how to search this kind of problem. Thanks again! – 김원중 Aug 15 '22 at 07:31

0 Answers0