Skip to content

Commit

Permalink
v1.8
Browse files Browse the repository at this point in the history
  • Loading branch information
tb69wn6127 committed Apr 30, 2015
1 parent 8f8e1a4 commit 2ce44da
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 1 deletion.
7 changes: 7 additions & 0 deletions changelog.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
변경사항
==============

v1.8
-------

+ ufp.math 모듈 추가함. [`tb69wn6127`_]
+ ufp.math 모듈에 rshift함수 추가함. [`tb69wn6127`_]
+ ufp.list 모듈에 preallocate 함수 추가함. [`tb69wn6127`_]

v1.7.1
-------

Expand Down
1 change: 1 addition & 0 deletions docs/reference/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
dict
path
pdf
math
list
descriptor
random
Expand Down
10 changes: 10 additions & 0 deletions docs/reference/math.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.. py:module:: ufp.math
.. py:currentmodule:: ufp.math
:py:mod:`math` 모듈
==========================

.. automodule:: ufp.math
:members:
:undoc-members:
:show-inheritance:
2 changes: 1 addition & 1 deletion ufp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from __future__ import unicode_literals, absolute_import

__title__ = 'ufp'
__version__ = '1.7.1'
__version__ = '1.8'
__author__ = '별님'
__author_email__ = 'w7dn1ng75r@gmail.com'
__license__ = 'GPL v3'
Expand Down
11 changes: 11 additions & 0 deletions ufp/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,17 @@

from __future__ import unicode_literals, absolute_import, division, print_function

def preallocate(size, value=None):
"""
size 만큼의 길이를 가진 list를 반환합니다. 리스트의 내용은 value로 채워집니다.
:param size: 할당 할 크기.
:type size: int
:param value: 초기화 할 값.
:return: size만큼 할당 된 list.
"""
return size * [value]

def chunks(list, step):
"""
list를 step 단위로 묶어 yield합니다.
Expand Down
22 changes: 22 additions & 0 deletions ufp/math.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env python
#-*- coding: utf-8 -*-

from __future__ import unicode_literals, absolute_import, division, print_function

def urshift(val, n):
"""
부호 없이 식을 비트 단위로 오른쪽으로 이동합니다.
자바스크립트의 >>> 연산자와 같은 역할을 합니다. 예를 들어 '(-1000) >>> 3'는 'ufp.math.rshift(-1000, 3)'와 같습니다.
.. 참조 : http://stackoverflow.com/questions/5832982/how-to-get-the-logical-right-binary-shift-in-python
:param val: 식
:param n: 비트 수
:return: 부호 없이 식을 비트 단위로 오른쪽으로 이동한 결과 값.
"""
if val >= 0:
return val >> n
else:
return ( val + 0x100000000 ) >> n
pass

0 comments on commit 2ce44da

Please sign in to comment.