1. 06 Apr, 2020 4 commits
  2. 03 Apr, 2020 4 commits
  3. 02 Apr, 2020 6 commits
    • da-woods's avatar
      Relaxed some of the checks on calling fused functions (GH-3381) · 2ca3f569
      da-woods authored
      Relaxed some of the checks of fused functions to be consistent with general CyFunctions.
      
      ```
       # cython: binding=True
      def f(arg):
        pass
      
      class C:  # or cdef class...
        f = f
        def g(self, ...):
          pass
      
      C.f(something) or C().f() # doesn't enforce any checks on the type of arg -
       # with a fused function it does.
      
      C.g(something) # assumes that self is "C" (at least for a cdef class)
       # but doesn't check it. A fused function enforces that it is C.
      
      C.f() # fails with a fused function claiming too few arguments, even though
       # default arguments may make it a valid call
      ```
      
      Obviously removing checks does make things a little less safe, but it
      is consistent with the more general function behaviour. (I'm doing
      this as part of a broad plan to abuse fused functions to be a bit
      cleverer about decorators, but I don't think the motivation hugely
      matters for this change)
      2ca3f569
    • Stefan Behnel's avatar
      Update changelog. · 830bdfac
      Stefan Behnel authored
      830bdfac
    • Stefan Behnel's avatar
    • Stefan Behnel's avatar
      Update changelog. · 5ab92ce5
      Stefan Behnel authored
      5ab92ce5
    • da-woods's avatar
      Concatenate strings in place if possible (GH-3451) · 76043d6e
      da-woods authored
      Optimized inplace operations for str/unicode so that they're
      genuinely done in place if no-one else needs the object. This
      is what CPython tries to do (and string concatenation was
      a point where it significantly beat Cython at times).
      
      This only works if the types are known at compile time, so with
      unknown types CPython will still be faster in some cases.
      
      Note: Uses slightly odd-macro trickery - does modify the input argument too
      (although only in places where it shouldn't matter).
      76043d6e
    • William Ayd's avatar
      Optimize builtin str() calls (GH-3478) · 2c8e7b22
      William Ayd authored
      2c8e7b22
  4. 01 Apr, 2020 5 commits
  5. 31 Mar, 2020 14 commits
  6. 26 Mar, 2020 4 commits
  7. 25 Mar, 2020 1 commit
    • Dmitry Shesterkin's avatar
      Avoid incorrect type calls from cython.declare and cython.cast in Shadow.py (GH-3244) · 48dc1f01
      Dmitry Shesterkin authored
      The following code:
      ```
      # cython: infer_types=True
      import cython
      
      @cython.cclass
      class Foo:
          a: cython.double
          b: cython.double
          c: cython.double
      
          def __init__(self, a: cython.double, b: cython.double ,c: cython.double):
              self.a = a
              self.b = b
              self.c = c
      
      def bar():
          l = []
          l.append(Foo(10, 20, 30))
      
          v = cython.declare(Foo, l[0])
          r = v.a + v.b
          print( r )
      
          v2 = cython.cast(Foo, l[0]) #Faster - No __Pyx_TypeTest() call
          r = v2.b + v2.c
          print( r )
      
      bar()
      ```
      works fine when compiled and throws an exception when interpreted: `TypeError: __init__() missing 2 required positional arguments: 'b' and 'c'`
      
      It could be fixed if we change implementations as shown in the patch.
      Also, added more tests for the cases I'm trying to fix
      NB: Removed execution of `test_declare(None)` to make sure that the new `none_declare()` test works instead. `test_declare(None)` doesn't throw exception in pure mode but does it in the native mode
      
      Replacing `hasattr(t, '__call__')` to `callable(t)` in the master branch broke the implementation and the tests because the construction was used to detect typedefs. To fix that I got rid of this check completely and replaced it to exact checks which also simplified the code
      
      Changed `declare` implementation when initializing arguments are not provided. Now it correctly works with typedefs of the user classes and also directly support arrays:
          ```
          >>> EmptyClassSyn = cython.typedef(EmptyClass)
          >>> cython.declare(EmptyClassSyn) is None
          True
          >>> cython.declare(cython.int[2]) is not None
          True
          ```
      Added missed return statement to `index_type` which made the following assigment possible:
          ```
              a = cython.declare(cython.int[2])
              a[0] = 1
          ```
      48dc1f01
  8. 24 Mar, 2020 2 commits