Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
satella
Manage
Activity
Members
Labels
Plan
Issues
1
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
public
satella
Commits
88bc421f
Unverified
Commit
88bc421f
authored
11 months ago
by
Piotr Maślanka
Browse files
Options
Downloads
Patches
Plain Diff
v2.25.5
parent
bdfacd06
No related branches found
No related tags found
No related merge requests found
Pipeline
#62043
passed with stages
in 1 minute and 43 seconds
Changes
3
Pipelines
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
CHANGELOG.md
+1
-0
1 addition, 0 deletions
CHANGELOG.md
satella/__init__.py
+1
-1
1 addition, 1 deletion
satella/__init__.py
satella/coding/structures/heaps/base.py
+15
-10
15 additions, 10 deletions
satella/coding/structures/heaps/base.py
with
17 additions
and
11 deletions
CHANGELOG.md
+
1
−
0
View file @
88bc421f
# v2.25.5
*
slight optimization for Heap.push_many
*
bugfix for Heap.push and a deprecation
# v2.25.4
...
...
This diff is collapsed.
Click to expand it.
satella/__init__.py
+
1
−
1
View file @
88bc421f
__version__
=
'
2.25.5
a2
'
__version__
=
'
2.25.5
'
This diff is collapsed.
Click to expand it.
satella/coding/structures/heaps/base.py
+
15
−
10
View file @
88bc421f
...
...
@@ -7,14 +7,6 @@ from satella.coding.decorators.decorators import wraps
from
satella.coding.typing
import
T
,
Predicate
def
_extras_to_one
(
fun
):
@wraps
(
fun
)
def
inner
(
self
,
a
,
*
args
,
**
kwargs
):
return
fun
(
self
,
((
a
,)
+
args
)
if
len
(
args
)
>
0
else
a
,
**
kwargs
)
return
inner
class
Heap
(
collections
.
UserList
,
tp
.
Generic
[
T
]):
"""
Sane heap as object - not like heapq.
...
...
@@ -52,8 +44,7 @@ class Heap(collections.UserList, tp.Generic[T]):
heapq
.
heapify
(
self
.
data
)
return
item
@_extras_to_one
def
push
(
self
,
item
:
T
)
->
None
:
def
push
(
self
,
item
:
T
,
*
args
)
->
None
:
"""
Use it like:
...
...
@@ -62,7 +53,14 @@ class Heap(collections.UserList, tp.Generic[T]):
or:
>>>
heap
.
push
(
4
,
myobject
)
However this syntax is
.. deprecated:: 2.25.5
It
'
s not legible
"""
if
args
:
item
=
(
item
,
*
args
)
heapq
.
heappush
(
self
.
data
,
item
)
def
__deepcopy__
(
self
,
memo
=
{})
->
'
Heap
'
:
...
...
@@ -147,6 +145,13 @@ class SetHeap(Heap):
#notthreadsafe
"""
def
push_many
(
self
,
items
:
tp
.
Iterable
[
T
])
->
None
:
"""
Not that much faster than inserting anything by hand
"""
for
item
in
items
:
self
.
push
(
item
)
def
__init__
(
self
,
from_list
:
tp
.
Optional
[
tp
.
Iterable
[
T
]]
=
None
):
super
().
__init__
(
from_list
=
from_list
)
self
.
set
=
set
(
self
.
data
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment