silly_giraffe
Joined 9 years ago
Karma
87
Submissions
11
Member since
Aug 11
Joined 9 years ago
Using the Python bindings, the biggest performance impact I discovered was ensuring that my jobs and tasks were represented as z3.Bool and not z3.Int (requiring a roundabout way to do a summation on z3.Bools). Something like:
tasks_this_tick = [(z3.Bool(task_id), 1) for task_id in current_tasks]
model.add(z3.PbLe(tasks_this_tick, max_tasks_per_tick + 1)The search space for this problem is enormous, but Z3 will produce an impressive result within a few minutes.
Those have different use cases. `sorted` is for situations where you would use a list comprehension and immediately consume the result vs `.sort` where you need the iterable sorted for future use.
As a quick scribble, you can do something like the following to sort random numbers in a single line:
result = sorted(random.random() for x in range(10))
From your Medium post: def list_sort(arr):
return arr.sort()
def sorted_builtin(arr):
return sorted(arr)
Only the `sorted_builtin` function returns the array, `list_sort` returns None. The `list_sort` function would have to become: def list_sort(arr):
arr.sort()
return arr
Edit: goofed the formattingThanks for making this resource available and giving it some exposure.