Skip to content

Commit

Permalink
Using pure C instead of cython. Now the C extension is as fast as pos…
Browse files Browse the repository at this point in the history
…sible.
  • Loading branch information
pylover committed Aug 19, 2016
1 parent 45e17cf commit 976a02a
Show file tree
Hide file tree
Showing 14 changed files with 530 additions and 5,077 deletions.
80 changes: 0 additions & 80 deletions .idea/dictionaries/vahid.xml

This file was deleted.

89 changes: 74 additions & 15 deletions .travis.yml
@@ -1,28 +1,87 @@


language: python

#env:
# - PYTHON=python PYSUF='' PYVER=2.7 PIPVER=''
# - PYTHON=python3 PYSUF='3' PYVER=3.2 PIPVER='==7.1.2'
# Default Python version is usually 2.7
python: 3.5
sudo: required
dist: trusty
#services: docker

os:
- linux
- osx


matrix:
exclude:
# Exclude the default Python 3.5 build
- python: 3.5

include:

- os: linux
python: 2.7

- os: linux
python: 3.3

- os: linux
python: 3.4

- os: linux
python: 3.5

- os: linux
python: nightly

- os: linux
python: pypy

- os: linux
python: pypy3

- os: osx
language: objective-c
python: 2.7
env:
- PY=2
- PY_SUFFIX=

- os: osx
language: objective-c
python: 3.5
env:
- PY=3
- PY_SUFFIX=3

python:
- "2.7"
- "3.3"
- "3.4"
- "3.5"
- "3.5-dev"
- "pypy"

before_install:
- sudo apt-get update
- sudo apt-get install python$( python -c 'import sys; print("%d.%d" % sys.version_info[:2])' )-dev || true
# HOSTNAME
- cat /etc/hosts # optionally check the content *before*
- sudo hostname "$(hostname | cut -c1-63)"
- sed -e "s/^\\(127\\.0\\.0\\.1.*\\)/\\1 $(hostname | cut -c1-63)/" /etc/hosts > /tmp/hosts
- sudo mv /tmp/hosts /etc/hosts
- cat /etc/hosts # optionally check the content *after*

# OSX
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update ; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" && "$PY" == "3" ]]; then brew install python$PY_SUFFIX; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then virtualenv venv -p python$PY_SUFFIX; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then source venv/bin/activate; fi

# LINUX
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get update ; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get install python$( python -c 'import sys; print("%d.%d" % sys.version_info[:2])' )-dev || true ; fi
- pip install -U pip setuptools wheel
- pip install -r requirement.txt


install:
- pip install -e .
- pip install -ve .

script:
coverage run --source khayyam $(which nosetests)
- if [[ "$TRAVIS_PYTHON_VERSION" == "3.5" ]]; then coverage run --source khayyam $(which nosetests) ; fi

after_success:
coveralls
- if [[ "$TRAVIS_PYTHON_VERSION" == "3.5" ]]; then coveralls ; fi
15 changes: 15 additions & 0 deletions TODO
Expand Up @@ -4,3 +4,18 @@
* Doc: Review JalaliDatetime documents
* Add two methods: d.next(SATURDAY) & d.previous(WEDNESDAY)
* Use compiled regex if matters in performance

win-py2-x86
win-py2-x64
cygwin-py2-x64
win-py3-x86
win-py3-x64
cygwin-py3-x86
osx-py2
osx-py3
linux-py2-x86
linux-py2-x64
linux-py3-x86
linux-py3-x64
armv7-py2
armv7-py3
2 changes: 1 addition & 1 deletion khayyam/__init__.py
Expand Up @@ -4,7 +4,7 @@
from .jalali_datetime import JalaliDatetime
from .timezones import TehranTimezone, Timezone

__version__ = '2.10.0'
__version__ = '2.10.0-dev0'


teh_tz = TehranTimezone()
Expand Down
32 changes: 16 additions & 16 deletions khayyam/algorithms.py
Expand Up @@ -5,28 +5,28 @@

try:
from .algorithms_c import \
is_leap_year, \
days_in_year, \
days_in_month, \
get_julian_day_from_gregorian, \
julian_day_from_jalali_date, \
jalali_date_from_julian_day, \
gregorian_date_from_julian_day, \
jalali_date_from_gregorian_date
is_jalali_leap_year, \
get_julian_day_from_gregorian_date, \
get_days_in_jalali_year, \
get_days_in_jalali_month, \
get_julian_day_from_jalali_date, \
get_jalali_date_from_julian_day, \
get_gregorian_date_from_julian_day, \
get_jalali_date_from_gregorian_date

except ImportError: # pragma: no cover
warnings.warn(
"The Cython extension is not available. Switching to fallback python pure algorithms, "
"so it's may be slower than C implementation of the algorithms.")
from .algorithms_pure import \
is_leap_year, \
days_in_year, \
days_in_month, \
get_julian_day_from_gregorian, \
julian_day_from_jalali_date, \
jalali_date_from_julian_day, \
gregorian_date_from_julian_day, \
jalali_date_from_gregorian_date
is_jalali_leap_year, \
get_julian_day_from_gregorian_date, \
get_days_in_jalali_year, \
get_days_in_jalali_month, \
get_julian_day_from_jalali_date, \
get_jalali_date_from_julian_day, \
get_gregorian_date_from_julian_day, \
get_jalali_date_from_gregorian_date



0 comments on commit 976a02a

Please sign in to comment.