> days_in_month 12:
> 31
> 30
> 28
> 31
> ...
> 30
> 31
> assign $days days_in_month[$month]
>
> This program consists of 2 operations (table jump and assignment)
> and 12 values. This makes a memory consumption of 12+2 = 14
Along the same lines, you could populate the table somewhat sparsely,
and
> Past a "many-small" certain point on numbers of hash-tables, if that's
> the right word, in a program, and intepreter process on a machine, is
> it be more time-efficient to allocate a 2**32-byte table? Are
> 'modulo' and 'doublesize' the only steps of the lookup process that it
> would eliminat
On Feb 17, 11:23 pm, greg <[EMAIL PROTECTED]> wrote:
> Wolfgang Draxinger wrote:
> > Somehow you seem to think, that a lookup table will require more
> > resources (memory I guess you thought) than a sequence of
> > comparisons. However you didn't take into account, that the
> > program code itself
Wolfgang Draxinger wrote:
> Somehow you seem to think, that a lookup table will require more
> resources (memory I guess you thought) than a sequence of
> comparisons. However you didn't take into account, that the
> program code itself requires memory, too (for the operation
> codes).
In Python,
> What shall there be missing? breaks? You noticed, that I defined
> some artificial architecture on purpose. "days_in_month 12:"
> tells it, that the next 12 blurps are tabular data, that can be
> indexed. If the "interpreter" hits the line "days_in_month 12:"
> it will unconditionally jump 12 ins
[EMAIL PROTECTED] wrote:
>> days_in_month 12:
>> 31
>> 30
>> 28
>> 31
>> ...
>> 30
>> 31
>> assign $days days_in_month[$month]
>
> This is missing
> days_in_month 12:
> 31
> break
> 30
> break
What shall there be missing? breaks? You noticed, that I defined
some artificial architecture on purpos
> days_in_month 12:
> 31
> 30
> 28
> 31
> ...
> 30
> 31
> assign $days days_in_month[$month]
This is missing
days_in_month 12:
31
break
30
break
Or the addition
add $x' $x offset
store $r0 $x'
assign $days $r0
Is that 4 ticks or 5; or 24 blips?
--
http://mail.python.org/mailman/listinfo/python-
On Feb 17, 7:05 am, Wolfgang Draxinger <[EMAIL PROTECTED]>
wrote:
> nexes wrote:
> > there is more data that needed to be assigned(i.e. a couple
> > megs of data) it would be simpler (and more efficient) to
> > do a compare rather then assigning all that data to an array,
> > since you are only goi
nexes wrote:
> there is more data that needed to be assigned(i.e. a couple
> megs of data) it would be simpler (and more efficient) to
> do a compare rather then assigning all that data to an array,
> since you are only going to be using 1 value and the rest
> of the data in the array is useless.
John Machin wrote:
> On Feb 17, 11:11 am, "Gabriel Genellina" <[EMAIL PROTECTED]>
> wrote:
>> En Sat, 16 Feb 2008 19:43:37 -0200, John Machin <[EMAIL PROTECTED]>
>> escribi�:
>>
>>> On Feb 16, 3:48 pm, Dan Bishop <[EMAIL PROTECTED]> wrote:
days_in_month = lambda m: m - 2 and 30 + bool(1 << m &
On Feb 17, 11:11 am, "Gabriel Genellina" <[EMAIL PROTECTED]>
wrote:
> En Sat, 16 Feb 2008 19:43:37 -0200, John Machin <[EMAIL PROTECTED]>
> escribi�:
>
> > On Feb 16, 3:48 pm, Dan Bishop <[EMAIL PROTECTED]> wrote:
>
> >> days_in_month = lambda m: m - 2 and 30 + bool(1 << m & 5546) or 28
>
> > Alter
En Sat, 16 Feb 2008 19:43:37 -0200, John Machin <[EMAIL PROTECTED]>
escribi�:
> On Feb 16, 3:48 pm, Dan Bishop <[EMAIL PROTECTED]> wrote:
>>
>> days_in_month = lambda m: m - 2 and 30 + bool(1 << m & 5546) or 28
>
> Alternatively:
>
> days_in_month = lambda m: m - 2 and 31 - ((m + 9) % 12 % 5 % 2)
On Feb 17, 9:57 am, [EMAIL PROTECTED] wrote:
> > days_in_month = lambda m: m - 2 and 31 - ((m + 9) % 12 % 5 % 2) or 28
>
> > the guts of which is slightly more elegant than the ancient writing
> > from which it was derived:
>
> Lacks citation.
Maxima mea culpa.
Pages 294-295 (in particular formul
> days_in_month = lambda m: m - 2 and 31 - ((m + 9) % 12 % 5 % 2) or 28
>
> the guts of which is slightly more elegant than the ancient writing
> from which it was derived:
Lacks citation.
--
http://mail.python.org/mailman/listinfo/python-list
[EMAIL PROTECTED] wrote:
> On Feb 15, 11:50 pm, Steve Holden <[EMAIL PROTECTED]> wrote:
>> Dan Bishop wrote:
>>> On Feb 15, 10:24 am, nexes <[EMAIL PROTECTED]> wrote:
[...]
What are everyone else's thoughts on this?
>>> days_in_month = lambda m: m - 2 and 30 + bool(1 << m & 5546) or 28
>> Eleg
On Feb 16, 3:48 pm, Dan Bishop <[EMAIL PROTECTED]> wrote:
> On Feb 15, 10:24 am, nexes <[EMAIL PROTECTED]> wrote:
>
>
>
> > Alright so me and my friend are having argument.
>
> > Ok the problem we had been asked a while back, to do a programming
> > exercise (in college)
> > That would tell you how
On Feb 15, 11:50 pm, Steve Holden <[EMAIL PROTECTED]> wrote:
> Dan Bishop wrote:
> > On Feb 15, 10:24 am, nexes <[EMAIL PROTECTED]> wrote:
> >> Alright so me and my friend are having argument.
>
> >> Ok the problem we had been asked a while back, to do a programming
> >> exercise (in college)
> >>
Dan Bishop wrote:
> On Feb 15, 10:24 am, nexes <[EMAIL PROTECTED]> wrote:
>> Alright so me and my friend are having argument.
>>
>> Ok the problem we had been asked a while back, to do a programming
>> exercise (in college)
>> That would tell you how many days there are in a month given a
>> specif
On Feb 15, 10:24 am, nexes <[EMAIL PROTECTED]> wrote:
> Alright so me and my friend are having argument.
>
> Ok the problem we had been asked a while back, to do a programming
> exercise (in college)
> That would tell you how many days there are in a month given a
> specific month.
>
> Ok I did my
On Feb 15, 12:32 pm, Grant Edwards <[EMAIL PROTECTED]> wrote:
> On 2008-02-15, Ivan Van Laningham <[EMAIL PROTECTED]> wrote:
>
> > Lookup tables are always significantly faster than a bunch of
> > ifs.
>
> Mostly always. It depends on what you mean by "lookup table",
> and it depends on how the la
If the data becomes much bigger, change your way of storing it, not the
code. You don't want to code hundreds of "if - elif - else" because you have
hundreds of different data, right ? TheDailyWTF is full of horror stories
like this, by the way ;-)
Data growth shouldn't result in modification in lo
On 2008-02-15, Ivan Van Laningham <[EMAIL PROTECTED]> wrote:
> Lookup tables are always significantly faster than a bunch of
> ifs.
Mostly always. It depends on what you mean by "lookup table",
and it depends on how the language implements things. If you
by "lookup table" you mean a linearly in
Hi All--
Lookup tables are always significantly faster than a bunch of ifs.
Metta,
Ivan
On Fri, Feb 15, 2008 at 10:10 AM, Tim Chase
<[EMAIL PROTECTED]> wrote:
> > Ok the problem we had been asked a while back, to do a programming
> > exercise (in college)
> > That would tell you how many days t
> -Original Message-
> From: [EMAIL PROTECTED] [mailto:python-
> [EMAIL PROTECTED] On Behalf Of nexes
> Sent: Friday, February 15, 2008 11:25 AM
> To: python-list@python.org
> Subject: Solve a Debate
>
> Alright so me and my friend are having argument.
>
> Ok the problem we had been asked
> Ok the problem we had been asked a while back, to do a programming
> exercise (in college)
> That would tell you how many days there are in a month given a
> specific month.
>
> Ok I did my like this (just pseudo):
>
> If month = 1 or 3 or etc
> noDays = 31
> Elseif month = 4 or 6
25 matches
Mail list logo