Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #66533
| References | <CAOF-KfiD=UgMg7GHiiPiT47zETJmrkicX4YTrxfh4=T2FSq64Q@mail.gmail.com> <mailman.7028.1392505094.18130.python-list@python.org> <roy-F1B3DF.18150315022014@news.panix.com> <ff79ffd3-7d39-4a55-95c3-ddada5ee4955@googlegroups.com> <CAOF-KfjNcT7B5eGvo=k2oXSuFj0YNJjiDCK9x83V9je88eG1Pg@mail.gmail.com> |
|---|---|
| Date | 2014-02-17 00:26 +1100 |
| Subject | Re: inheriting a large python code base |
| From | Chris Angelico <rosuav@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.7054.1392557224.18130.python-list@python.org> (permalink) |
On Sun, Feb 16, 2014 at 11:59 PM, Rita <rmorgan466@gmail.com> wrote:
> when I do profiling is it possible to find out if I am spending a lot of
> time in type conversion?
> it seems I am not.
I would guess that you don't. But in Python, type conversion is like
any other function call:
value = int("12345")
So you can test for it the same way you would any other.
> Also, is it possible to predeclare a type in python?
> Similar to C: int i=0;
>
No, because in Python, variables/names don't have types - only
objects/values do. You can simply initialize i to 0, in the obvious
way:
i = 0
And if you never put anything but an integer into i, it'll always be
an integer. That's about as close as you'll get to an "integer
variable" like C has. (Python's idea of an integer is rather better
than C's, of course; C's 'int' type is a machine word, so it can't
store values greater than 2**32 or 2**64 or whatever the limit is, but
Python's int can store any integer you have RAM enough to store.)
ChrisA
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
Re: inheriting a large python code base Cameron Simpson <cs@zip.com.au> - 2014-02-16 09:32 +1100
Re: inheriting a large python code base Roy Smith <roy@panix.com> - 2014-02-15 18:15 -0500
Re: inheriting a large python code base Rustom Mody <rustompmody@gmail.com> - 2014-02-15 19:06 -0800
Re: inheriting a large python code base Rita <rmorgan466@gmail.com> - 2014-02-16 07:59 -0500
Re: inheriting a large python code base Chris Angelico <rosuav@gmail.com> - 2014-02-17 00:26 +1100
csiph-web