-
Notifications
You must be signed in to change notification settings - Fork 274
Open
Description
Is your feature request related to a problem? Please describe.
__init__ method is not used in PySCIPOpt due to the SCIP pointer.
So create comes out to instead of __init__.
And it could still see __init__ in .create.
The chain to generate an instance via __init__.
- Run
__new__and return a empty instance - Run
__init__and return this instance.
Describe the solution you'd like
use __new__ to generate a instance. It could avoid running any code in __init__.
And a little speed up via skipping the checking.
cdef class Solution:
def __init__(self):
raise ValueError
@staticmethod
cdef create(SCIP* scip, SCIP_SOL* sol):
if scip == NULL:
raise Warning("cannot create Solution with SCIP* == NULL")
cdef Solution res = Solution.__new__(Solution)
res.sol = sol
res.scip = scip
return resuse __init__ to generate a instance
cdef class Solution:
def __init__(self, raise_error = False):
if not raise_error:
raise ValueError
@staticmethod
cdef create(SCIP* scip, SCIP_SOL* scip_sol):
if scip == NULL:
raise Warning("cannot create Solution with SCIP* == NULL")
sol = Solution(True)
sol.sol = scip_sol
sol.scip = scip
return solMetadata
Metadata
Assignees
Labels
No labels