create account

Python 이 Java 보다 좋은 이유 1 by kdj

View this thread on: hive.blogpeakd.comecency.com
· @kdj ·
$26.53
Python 이 Java 보다 좋은 이유 1
어떤 언어가 어떤 언어보다 좋은 이유는 매우 상대적인 이유입니다.
성능면에서 C 가 제일 좋다라고 한다면 다른 언어들은 다 무릎을 꿇어야 할지도 모릅니다.
다만 이런 저런 특성이 있다는 점을 참고하시면 좋을 것 같습니다.

# Python
- 숫자도 객체이며, 그리고 아주 긴 숫자도 담을 수 있습니다.

# Java
 - java.lang 패키지에서는 Integer, Long, Float 등등의 클래가 있으므로 숫자를 객체화 시킬 수 있습니다.
 - 계속해서 이 클래스의 인스턴스를 new, new 하면 성능 저하가 있습니다.
 - BigInteger 라는 것도 있습니다만, 그다지 유용하진 않습니다

# 비교 평가
- 대부분의 숫자에서 64비트 이상을 쓰는 경우가 흔하지는 않으므로, Python 이 다소 우월
- python 의 dir 은 타입(클래스)의 속성을 모두 보여줍니다.
  이렇게 많은 줄은 몰랐습니다.
  사실 a + b 는 a.\_\_add__(b) 입니다. 어떤 타입에서든 \_\_add__ 를 정의한다면 + 를 오버로딩 할 수 있습니다.
- OOP 의 대명사로 알려진 Java 는 이쯤에서 우울 모드로 빠집니다.

<br>
~~~~
$ python
Python 2.7.12 (default, Nov 19 2016, 06:48:10) 
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> a = 1120382710387210387210387018701870128471827308127308217382170382713
>>> type(a)
<type 'long'>
>>> a
1120382710387210387210387018701870128471827308127308217382170382713L
>>> dir(a)
['__abs__', '__add__', '__and__', '__class__', '__cmp__', '__coerce__',
 '__delattr__', '__div__', '__divmod__', '__doc__', '__float__',
 '__floordiv__', '__format__', '__getattribute__', '__getnewargs__',
 '__hash__', '__hex__', '__index__', '__init__', '__int__', '__invert__',
 '__long__', '__lshift__', '__mod__', '__mul__', '__neg__', '__new__',
 '__nonzero__', '__oct__', '__or__', '__pos__', '__pow__', '__radd__',
 '__rand__', '__rdiv__', '__rdivmod__', '__reduce__', '__reduce_ex__',
 '__repr__', '__rfloordiv__', '__rlshift__', '__rmod__', '__rmul__',
 '__ror__', '__rpow__', '__rrshift__', '__rshift__', '__rsub__',
 '__rtruediv__', '__rxor__', '__setattr__', '__sizeof__', '__str__', '__sub__',
 '__subclasshook__', '__truediv__', '__trunc__', '__xor__',
 'bit_length', 'conjugate', 'denominator', 'imag', 'numerator', 'real']
>>> a.__class__
<type 'long'>
>>> a.__add__(12312321321312)
1120382710387210387210387018701870128471827308127308229694491704025L
~~~~
👍  , , , , , , , , , , , , , , , , , , , , ,
properties (23)
authorkdj
permlinkpython-java-1
categorykr-dev
json_metadata{"tags":["kr-dev","kr","java","python"],"app":"steemit/0.1","format":"markdown"}
created2017-06-25 16:16:42
last_update2017-06-25 16:16:42
depth0
children0
last_payout2017-07-02 16:16:42
cashout_time1969-12-31 23:59:59
total_payout_value24.688 HBD
curator_payout_value1.838 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length1,911
author_reputation4,188,781,313,300
root_title"Python 이 Java 보다 좋은 이유 1"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id6,061,134
net_rshares2,469,149,707,188
author_curate_reward""
vote details (22)